CourseWareServices.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using EMISOnline.Entities;
  6. using EMISOnline.ViewModel.Educational;
  7. using Bowin.Common.Linq.Entity;
  8. using EMISOnline.DataLogic.Educational;
  9. using System.Linq.Expressions;
  10. using Bowin.Common.Linq;
  11. namespace EMISOnline.CommonLogic.EducationalServices
  12. {
  13. public class CourseWareServices : BaseServices, ICourseWareServices
  14. {
  15. public CourseWareDAL CourseWareDAL { get; set; }
  16. public IGridResultSet<CourseWareView> GetCourseWareList(int pageIndex, int pageSize, string CourseVideoName,DateTime? beginTime, DateTime? endTime)
  17. {
  18. Expression<Func<CourseWareView, bool>> exp = (e => true);
  19. //if (!string.IsNullOrEmpty(grademajorName))
  20. //{
  21. // exp = exp.And(e => e.GrademajorName.Contains(grademajorName.Trim()));
  22. //}
  23. //if (!string.IsNullOrEmpty(courseName))
  24. //{
  25. // exp = exp.And(e => e.CoursematerialName.Contains(courseName.Trim()));
  26. //}
  27. //if (!string.IsNullOrEmpty(createUser))
  28. //{
  29. // exp = exp.And(e => e.CreateUserName.Contains(createUser.Trim()));
  30. //}
  31. if (!string.IsNullOrEmpty(CourseVideoName))
  32. {
  33. exp = exp.And(e => e.CourseVideoName.Contains(CourseVideoName.Trim()));
  34. }
  35. if (beginTime.HasValue)
  36. {
  37. exp = exp.And(e => e.CreateTime >= beginTime);
  38. }
  39. if (endTime.HasValue)
  40. {
  41. DateTime d = endTime.Value.AddDays(1);
  42. exp = exp.And(e => e.CreateTime <= d);
  43. }
  44. var list = CourseWareDAL.GetCourseWareList().Where(exp).OrderByDescending(e => e.GrademajorName).ThenBy(e => e.CoursematerialName).ThenBy(e => e.CourseVideoName)
  45. .ThenByDescending(e => e.CreateTime).ToGridResultSet(pageIndex, pageSize);
  46. return list;
  47. }
  48. }
  49. }