123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using EMISOnline.Entities;
- using EMISOnline.DataLogic.Educational;
- using EMISOnline.ViewModel.Educational;
- using Bowin.Common.Linq.Entity;
- using Bowin.Common.Linq;
- using System.Linq.Expressions;
- using System.Web.Script.Serialization;
- using EMISOnline.ViewModel;
- namespace EMISOnline.CommonLogic.EducationalServices
- {
- public class CourseBuildServices : BaseServices, ICourseBuildServices
- {
- public CourseDAL CourseDAL { get; set; }
- public CourseBuildDAL CourseBuildDAL { get; set; }
- public IGridResultSet<CoursematerView> GetCoursematerList(int pageIndex, int pageSize, string courseName, string CourseCode)
- {
- Expression<Func<CoursematerView, bool>> exp = (e => true);
- if (!string.IsNullOrEmpty(courseName))
- {
- exp = exp.And(e => e.CourseName.Contains(courseName.Trim()));
- }
- if (!string.IsNullOrEmpty(CourseCode))
- {
- exp = exp.And(e => e.CourseCode.Contains(CourseCode.Trim()));
- }
- var list = CourseDAL.GetCourseList().Where(exp).OrderByDescending(r => r.CreateTime).ToGridResultSet(pageIndex, pageSize);
- return list;
- }
- public IGridResultSet<CourseChapterView> GetCourseChapterList(int pageIndex, int pageSize, string chapterName, Guid? CoursematerialID)
- {
- Expression<Func<CourseChapterView, bool>> exp = (e => true);
- if (!string.IsNullOrEmpty(chapterName))
- {
- exp = exp.And(e => e.Name.Contains(chapterName.Trim()));
- }
- if (CoursematerialID.HasValue)
- {
- exp = exp.And(e => e.CoursematerialID == CoursematerialID);
- }
- var list = CourseBuildDAL.GetCourseChapterList().Where(exp).OrderByDescending(r => r.CreateTime).ToGridResultSet(pageIndex, pageSize);
- return list;
- }
- public IList<CourseChapterView> GetCourseChapterList(Guid? CoursematerialID)
- {
- Expression<Func<CourseChapterView, bool>> exp = (e => true);
- if (CoursematerialID.HasValue)
- {
- exp = exp.And(e => e.CoursematerialID == CoursematerialID);
- }
- var list = CourseBuildDAL.GetCourseChapterList().Where(exp).OrderBy(r => r.OrderID).ToList();
- return list;
- }
- public IGridResultSet<CourseVideoView> GetChaperVideoList(Guid? CourseChapterID)
- {
- Expression<Func<CourseVideoView, bool>> exp = (e => true);
- if (CourseChapterID.HasValue)
- {
- exp = exp.And(e => e.CourseChapterID == CourseChapterID);
- }
- var list = CourseBuildDAL.GetChaperVideoList().Where(exp).OrderBy(r => r.CreateTime).ToList();
- var result = new GridResultSet<CourseVideoView>
- {
- rows = list
- };
- result.total = list.Count;
- return result;
- }
- public IGridResultSet<CourseVideoView> GetVideoList(int pageIndex, int pageSize, string videoName)
- {
- Expression<Func<CourseVideoView, bool>> exp = (e => true);
- if (!string.IsNullOrEmpty(videoName))
- {
- exp = exp.And(e => e.Name.Contains(videoName.Trim()));
- }
- var list = CourseBuildDAL.GetVideoList().Where(exp).OrderByDescending(r => r.CreateTime).ToGridResultSet(pageIndex, pageSize);
- return list;
- }
- public void AddChapter(Guid? ParentCourseChapterID, Guid? CourseChapterID, string Name, int? OrderID,
- int VideoTypeID, Guid? CourseVideoID, string OuterVideoUrl,
- Guid CoursematerialID)
- {
- EM_CourseChapter chapter = new EM_CourseChapter();
- if (CourseChapterID.HasValue && CourseChapterID != Guid.Empty)//修改
- {
- chapter = CourseBuildDAL.GetChapterSingle(CourseChapterID.Value);
- chapter.ParentCourseChapterID = ParentCourseChapterID;
- chapter.Name = Name;
- chapter.OrderID = OrderID;
- chapter.CoursematerialID = CoursematerialID;
- chapter.VideoTypeID = VideoTypeID;
- chapter.OuterVideoUrl = OuterVideoUrl;
- UnitOfWork.Update(chapter);
- }
- else//新增
- {
- chapter.CourseChapterID = Guid.NewGuid();
- chapter.ParentCourseChapterID = ParentCourseChapterID;
- chapter.Name = Name;
- chapter.OrderID = OrderID;
- chapter.CreateTime = DateTime.Now;
- chapter.CoursematerialID = CoursematerialID;
- chapter.VideoTypeID = VideoTypeID;
- chapter.OuterVideoUrl = OuterVideoUrl;
- chapter.RecordStatus = 1;
- UnitOfWork.Add(chapter);
- }
- if (CourseVideoID.HasValue && VideoTypeID == (int)EM_OnlineVideoType.Local)
- {
- CourseBuildDAL.DelChapterVideo(chapter.CourseChapterID);
- EM_CourseChapter_Video chapterVideo = new EM_CourseChapter_Video();
- chapterVideo.CourseChapterID = chapter.CourseChapterID;
- chapterVideo.CourseVideoID = CourseVideoID.Value;
- UnitOfWork.Add(chapterVideo);
- }
- UnitOfWork.Commit();
- }
- public void DeleteChapter(Guid CourseChapterID)
- {
- CourseBuildDAL.DelChapter(CourseChapterID);
- UnitOfWork.Commit();
- }
- public bool IsAnySubChapter(Guid ParentCourseChapterID)
- {
- return CourseBuildDAL.IsAnySubChapter(ParentCourseChapterID);
- }
- }
- }
|