using System; using System.Collections.Generic; using System.Linq; using System.Text; using EMISOnline.Entities; using EMISOnline.DataLogic.Repositories; using EMISOnline.ViewModel.Educational; using System.Linq.Expressions; using Bowin.Common.Linq; namespace EMISOnline.DataLogic.Educational { public class CourseBuildDAL { public CourseChapterRepository CourseChapterRepository { get; set; } public UserRepository UserRepository { get; set; } public CourseVideoRepository CourseVideoRepository { get; set; } public CourseChapter_VideoRepository CourseChapter_VideoRepository { get; set; } public IQueryable GetCourseChapterList() { var query = from c in CourseChapterRepository.Entities join u in UserRepository.Entities on c.CreateUserID equals u.UserID into chaCrus from cu in chaCrus.DefaultIfEmpty() select new CourseChapterView { CourseChapterID = c.CourseChapterID, CoursematerialID = c.CoursematerialID, Name = c.Name, OrderID = c.OrderID, ParentCourseChapterID = c.ParentCourseChapterID, VideoTypeID = c.VideoTypeID, OuterVideoUrl = c.OuterVideoUrl, CreateTime = c.CreateTime, CreateUserID = c.CreateUserID, CreateUserName = cu.Name }; return query; } public IQueryable GetChaperVideoList() { var query = from v in CourseVideoRepository.Entities join ccv in CourseChapter_VideoRepository.Entities on v.CourseVideoID equals ccv.CourseVideoID select new CourseVideoView { CourseVideoID = v.CourseVideoID, Name = v.Name, PlayUrl = v.PlayUrl, CreateUserID = v.CreateUserID, CreateTime = v.CreateTime, CourseChapterID = ccv.CourseChapterID }; return query; } public IQueryable GetVideoList() { var query = from v in CourseVideoRepository.Entities select new CourseVideoView { CourseVideoID = v.CourseVideoID, Name = v.Name, PlayUrl = v.PlayUrl, CreateUserID = v.CreateUserID, CreateTime = v.CreateTime }; return query; } public EM_CourseChapter GetChapterSingle(Guid CourseChapterID) { return CourseChapterRepository.Entities.Where(c => c.CourseChapterID == CourseChapterID).FirstOrDefault(); } public void DelChapterVideo(Guid CourseChapterID) { Expression> exp = (e => true); exp = exp.And(e => e.CourseChapterID == CourseChapterID); CourseChapter_VideoRepository.UnitOfWork.Remove(exp); } public void DelChapter(Guid CourseChapterID) { DelChapterVideo(CourseChapterID); Expression> exp = (e => true); exp = exp.And(e => e.CourseChapterID == CourseChapterID); CourseChapterRepository.UnitOfWork.Remove(exp); } public bool IsAnySubChapter(Guid ParentCourseChapterID) { return CourseChapterRepository.Entities.Where(c => c.ParentCourseChapterID == ParentCourseChapterID).Any(); } } }