CourseBuildServices.cs 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using EMISOnline.Entities;
  6. using EMISOnline.DataLogic.Educational;
  7. using EMISOnline.ViewModel.Educational;
  8. using Bowin.Common.Linq.Entity;
  9. using Bowin.Common.Linq;
  10. using System.Linq.Expressions;
  11. using System.Web.Script.Serialization;
  12. using EMISOnline.ViewModel;
  13. namespace EMISOnline.CommonLogic.EducationalServices
  14. {
  15. public class CourseBuildServices : BaseServices, ICourseBuildServices
  16. {
  17. public CourseDAL CourseDAL { get; set; }
  18. public CourseBuildDAL CourseBuildDAL { get; set; }
  19. public IGridResultSet<CoursematerView> GetCoursematerList(int pageIndex, int pageSize, string courseName, string CourseCode)
  20. {
  21. Expression<Func<CoursematerView, bool>> exp = (e => true);
  22. if (!string.IsNullOrEmpty(courseName))
  23. {
  24. exp = exp.And(e => e.CourseName.Contains(courseName.Trim()));
  25. }
  26. if (!string.IsNullOrEmpty(CourseCode))
  27. {
  28. exp = exp.And(e => e.CourseCode.Contains(CourseCode.Trim()));
  29. }
  30. var list = CourseDAL.GetCourseList().Where(exp).OrderByDescending(r => r.CreateTime).ToGridResultSet(pageIndex, pageSize);
  31. return list;
  32. }
  33. public IGridResultSet<CourseChapterView> GetCourseChapterList(int pageIndex, int pageSize, string chapterName, Guid? CoursematerialID)
  34. {
  35. Expression<Func<CourseChapterView, bool>> exp = (e => true);
  36. if (!string.IsNullOrEmpty(chapterName))
  37. {
  38. exp = exp.And(e => e.Name.Contains(chapterName.Trim()));
  39. }
  40. if (CoursematerialID.HasValue)
  41. {
  42. exp = exp.And(e => e.CoursematerialID == CoursematerialID);
  43. }
  44. var list = CourseBuildDAL.GetCourseChapterList().Where(exp).OrderByDescending(r => r.CreateTime).ToGridResultSet(pageIndex, pageSize);
  45. return list;
  46. }
  47. public IList<CourseChapterView> GetCourseChapterList(Guid? CoursematerialID)
  48. {
  49. Expression<Func<CourseChapterView, bool>> exp = (e => true);
  50. if (CoursematerialID.HasValue)
  51. {
  52. exp = exp.And(e => e.CoursematerialID == CoursematerialID);
  53. }
  54. var list = CourseBuildDAL.GetCourseChapterList().Where(exp).OrderBy(r => r.OrderID).ToList();
  55. return list;
  56. }
  57. public IGridResultSet<CourseVideoView> GetChaperVideoList(Guid? CourseChapterID)
  58. {
  59. Expression<Func<CourseVideoView, bool>> exp = (e => true);
  60. if (CourseChapterID.HasValue)
  61. {
  62. exp = exp.And(e => e.CourseChapterID == CourseChapterID);
  63. }
  64. var list = CourseBuildDAL.GetChaperVideoList().Where(exp).OrderBy(r => r.CreateTime).ToList();
  65. var result = new GridResultSet<CourseVideoView>
  66. {
  67. rows = list
  68. };
  69. result.total = list.Count;
  70. return result;
  71. }
  72. public IGridResultSet<CourseVideoView> GetVideoList(int pageIndex, int pageSize, string videoName)
  73. {
  74. Expression<Func<CourseVideoView, bool>> exp = (e => true);
  75. if (!string.IsNullOrEmpty(videoName))
  76. {
  77. exp = exp.And(e => e.Name.Contains(videoName.Trim()));
  78. }
  79. var list = CourseBuildDAL.GetVideoList().Where(exp).OrderByDescending(r => r.CreateTime).ToGridResultSet(pageIndex, pageSize);
  80. return list;
  81. }
  82. public void AddChapter(Guid? ParentCourseChapterID, Guid? CourseChapterID, string Name, int? OrderID,
  83. int VideoTypeID, Guid? CourseVideoID, string OuterVideoUrl,
  84. Guid CoursematerialID)
  85. {
  86. EM_CourseChapter chapter = new EM_CourseChapter();
  87. if (CourseChapterID.HasValue && CourseChapterID != Guid.Empty)//修改
  88. {
  89. chapter = CourseBuildDAL.GetChapterSingle(CourseChapterID.Value);
  90. chapter.ParentCourseChapterID = ParentCourseChapterID;
  91. chapter.Name = Name;
  92. chapter.OrderID = OrderID;
  93. chapter.CoursematerialID = CoursematerialID;
  94. chapter.VideoTypeID = VideoTypeID;
  95. chapter.OuterVideoUrl = OuterVideoUrl;
  96. UnitOfWork.Update(chapter);
  97. }
  98. else//新增
  99. {
  100. chapter.CourseChapterID = Guid.NewGuid();
  101. chapter.ParentCourseChapterID = ParentCourseChapterID;
  102. chapter.Name = Name;
  103. chapter.OrderID = OrderID;
  104. chapter.CreateTime = DateTime.Now;
  105. chapter.CoursematerialID = CoursematerialID;
  106. chapter.VideoTypeID = VideoTypeID;
  107. chapter.OuterVideoUrl = OuterVideoUrl;
  108. chapter.RecordStatus = 1;
  109. UnitOfWork.Add(chapter);
  110. }
  111. if (CourseVideoID.HasValue && VideoTypeID == (int)EM_OnlineVideoType.Local)
  112. {
  113. CourseBuildDAL.DelChapterVideo(chapter.CourseChapterID);
  114. EM_CourseChapter_Video chapterVideo = new EM_CourseChapter_Video();
  115. chapterVideo.CourseChapterID = chapter.CourseChapterID;
  116. chapterVideo.CourseVideoID = CourseVideoID.Value;
  117. UnitOfWork.Add(chapterVideo);
  118. }
  119. UnitOfWork.Commit();
  120. }
  121. public void DeleteChapter(Guid CourseChapterID)
  122. {
  123. CourseBuildDAL.DelChapter(CourseChapterID);
  124. UnitOfWork.Commit();
  125. }
  126. public bool IsAnySubChapter(Guid ParentCourseChapterID)
  127. {
  128. return CourseBuildDAL.IsAnySubChapter(ParentCourseChapterID);
  129. }
  130. }
  131. }