CourseBuildDAL.cs 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using EMISOnline.Entities;
  6. using EMISOnline.DataLogic.Repositories;
  7. using EMISOnline.ViewModel.Educational;
  8. using System.Linq.Expressions;
  9. using Bowin.Common.Linq;
  10. namespace EMISOnline.DataLogic.Educational
  11. {
  12. public class CourseBuildDAL
  13. {
  14. public CourseChapterRepository CourseChapterRepository { get; set; }
  15. public UserRepository UserRepository { get; set; }
  16. public CourseVideoRepository CourseVideoRepository { get; set; }
  17. public CourseChapter_VideoRepository CourseChapter_VideoRepository { get; set; }
  18. public IQueryable<CourseChapterView> GetCourseChapterList()
  19. {
  20. var query = from c in CourseChapterRepository.Entities
  21. join u in UserRepository.Entities on c.CreateUserID equals u.UserID into chaCrus
  22. from cu in chaCrus.DefaultIfEmpty()
  23. select new CourseChapterView
  24. {
  25. CourseChapterID = c.CourseChapterID,
  26. CoursematerialID = c.CoursematerialID,
  27. Name = c.Name,
  28. OrderID = c.OrderID,
  29. ParentCourseChapterID = c.ParentCourseChapterID,
  30. VideoTypeID = c.VideoTypeID,
  31. OuterVideoUrl = c.OuterVideoUrl,
  32. CreateTime = c.CreateTime,
  33. CreateUserID = c.CreateUserID,
  34. CreateUserName = cu.Name
  35. };
  36. return query;
  37. }
  38. public IQueryable<CourseVideoView> GetChaperVideoList()
  39. {
  40. var query = from v in CourseVideoRepository.Entities
  41. join ccv in CourseChapter_VideoRepository.Entities on v.CourseVideoID equals ccv.CourseVideoID
  42. select new CourseVideoView
  43. {
  44. CourseVideoID = v.CourseVideoID,
  45. Name = v.Name,
  46. PlayUrl = v.PlayUrl,
  47. CreateUserID = v.CreateUserID,
  48. CreateTime = v.CreateTime,
  49. CourseChapterID = ccv.CourseChapterID
  50. };
  51. return query;
  52. }
  53. public IQueryable<CourseVideoView> GetVideoList()
  54. {
  55. var query = from v in CourseVideoRepository.Entities
  56. select new CourseVideoView
  57. {
  58. CourseVideoID = v.CourseVideoID,
  59. Name = v.Name,
  60. PlayUrl = v.PlayUrl,
  61. CreateUserID = v.CreateUserID,
  62. CreateTime = v.CreateTime
  63. };
  64. return query;
  65. }
  66. public EM_CourseChapter GetChapterSingle(Guid CourseChapterID)
  67. {
  68. return CourseChapterRepository.Entities.Where(c => c.CourseChapterID == CourseChapterID).FirstOrDefault();
  69. }
  70. public void DelChapterVideo(Guid CourseChapterID)
  71. {
  72. Expression<Func<EM_CourseChapter_Video, bool>> exp = (e => true);
  73. exp = exp.And(e => e.CourseChapterID == CourseChapterID);
  74. CourseChapter_VideoRepository.UnitOfWork.Remove(exp);
  75. }
  76. public void DelChapter(Guid CourseChapterID)
  77. {
  78. DelChapterVideo(CourseChapterID);
  79. Expression<Func<EM_CourseChapter, bool>> exp = (e => true);
  80. exp = exp.And(e => e.CourseChapterID == CourseChapterID);
  81. CourseChapterRepository.UnitOfWork.Remove(exp);
  82. }
  83. public bool IsAnySubChapter(Guid ParentCourseChapterID)
  84. {
  85. return CourseChapterRepository.Entities.Where(c => c.ParentCourseChapterID == ParentCourseChapterID).Any();
  86. }
  87. }
  88. }