123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- 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<CourseChapterView> 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<CourseVideoView> 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<CourseVideoView> 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<Func<EM_CourseChapter_Video, bool>> exp = (e => true);
- exp = exp.And(e => e.CourseChapterID == CourseChapterID);
- CourseChapter_VideoRepository.UnitOfWork.Remove(exp);
- }
- public void DelChapter(Guid CourseChapterID)
- {
- DelChapterVideo(CourseChapterID);
- Expression<Func<EM_CourseChapter, bool>> 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();
- }
- }
- }
|