using System; using System.Collections.Generic; using System.Linq; using System.Text; using EMIS.DataLogic.Repositories; using EMIS.DataLogic.Common.Cultureplan; using EMIS.ViewModel.SelectCourse; using System.Linq.Expressions; using EMIS.Entities; using EMIS.ViewModel; namespace EMIS.DataLogic.SelectCourse { public class FreeSelectionCourseDAL { public FreeSelectionCouseRepository FreeSelectionCouseRepository { get; set; } public FreeSelectionCouseTeachingSettingRepository FreeSelectionCouseTeachingSettingRepository { get; set; } public Lazy CoursematerialDAL { get; set; } public DictionaryItemRepository DictionaryItemRepository { get; set; } public IQueryable GetFreeSelectionCourseViewQueryable(Expression> exp) { var query = from fsc in FreeSelectionCouseRepository.GetList(exp) join fscts in FreeSelectionCouseTeachingSettingRepository.Entities on fsc.FreeSelectionCouseID equals fscts.FreeSelectionCouseID join cm in CoursematerialDAL.Value.GetCoursematerialViewQueryable(x => true) on fsc.CoursematerialID equals cm.CoursematerialID join dicc in DictionaryItemRepository.GetList(x => x.DictionaryCode == typeof(CF_CourseCategory).Name) on fsc.CourseCategoryID equals dicc.Value into ddicc from edicc in ddicc.DefaultIfEmpty() join dict in DictionaryItemRepository.GetList(x => x.DictionaryCode == typeof(CF_CourseType).Name) on fsc.CourseTypeID equals dict.Value into ddict from edict in ddict.DefaultIfEmpty() join dicq in DictionaryItemRepository.GetList(x => x.DictionaryCode == typeof(CF_CourseQuality).Name) on fsc.CourseQualityID equals dicq.Value into ddicq from edicq in ddicq.DefaultIfEmpty() join dics in DictionaryItemRepository.GetList(x => x.DictionaryCode == typeof(CF_CourseStructure).Name) on fsc.CourseStructureID equals dics.Value into ddics from edics in ddics.DefaultIfEmpty() join disyn in DictionaryItemRepository.GetList(x => x.DictionaryCode == typeof(CF_SchoolyearNum).Name) on fsc.SchoolyearNumID equals disyn.Value into ddisyn from edisyn in ddisyn.DefaultIfEmpty() join disc in DictionaryItemRepository.GetList(x => x.DictionaryCode == typeof(CF_Semester).Name) on fsc.SchoolcodeID equals disc.Value into ddisc from edisc in ddisc.DefaultIfEmpty() //join dist in DictionaryItemRepository.GetList(x => x.DictionaryCode == typeof(CF_Startterm).Name) // on fsc.StarttermID equals dist.Value into ddist //from edist in ddist.DefaultIfEmpty() join diem in DictionaryItemRepository.GetList(x => x.DictionaryCode == typeof(CF_ExaminationMode).Name) on fsc.ExaminationModeID equals diem.Value into ddiem from ediem in ddiem.DefaultIfEmpty() join ditl in DictionaryItemRepository.GetList(x => x.DictionaryCode == typeof(CF_Teachinglanguage).Name) on fsc.TeachinglanguageID equals ditl.Value into dditl from editl in dditl.DefaultIfEmpty() select new FreeSelectionCourseView { FreeSelectionCouseID = fsc.FreeSelectionCouseID, //No = fsc.No, CollegeID = fsc.CF_Department.CollegeID, DepartmentID = fsc.DepartmentID, DepartmentName = fsc.CF_Department.Name, CourseStructureID = fsc.CourseStructureID, CourseStructureName = edics.Name, CourseCategoryID = fsc.CourseCategoryID, CourseCategoryName = edicc.Name, CourseTypeID = fsc.CourseTypeID, CourseTypeName = edict.Name, CourseQualityID = fsc.CourseQualityID, CourseQualityName = edicq.Name, ExaminationModeID = fsc.ExaminationModeID, ExaminationModeName = ediem.Name, TeachinglanguageID = fsc.TeachinglanguageID, TeachinglanguageName = editl.Name, SchoolyearNumID = fsc.SchoolyearNumID, SchoolyearNumName = edisyn.Name, SchoolcodeID = fsc.SchoolcodeID, SchoolcodeName = edisc.Name, PracticeTypeID=fsc.PracticeTypeID, //StarttermID = fsc.StarttermID, //StarttermName = edist.Name, IsEnable = (bool)fsc.IsEnable, Credit = fscts.Credit??0, TheoryCourse = fscts.TheoryCourse, Practicehours = fscts.Practicehours, Trialhours = fscts.Trialhours, Totalhours=((fscts.TheoryCourse ?? 0) + (fscts.Practicehours ?? 0) + (fscts.Trialhours ?? 0)), WeeklyHours = fscts.WeeklyHours, WeeklyNum = fscts.WeeklyNum, TheoryWeeklyNum = fscts.TheoryWeeklyNum, PracticeWeeklyNum = fscts.PracticeWeeklyNum, TrialWeeklyNum = fscts.TrialWeeklyNum, StartWeeklyNum = fscts.StartWeeklyNum, EndWeeklyNum = fscts.EndWeeklyNum, CoursematerialID = cm.CoursematerialID, CourseCode = cm.CourseCode, CourseName = cm.CourseName, CreateTime = fsc.CreateTime, CreateUserID = fsc.CreateUserID, ResultTypeID=fsc.ResultTypeID, Remark = fsc.Remark }; return query; } public IQueryable GetTeachingModeTypeViewQueryable(Expression> exp) { var query = from fsc in FreeSelectionCouseRepository.GetList(exp) from fsctm in fsc.EM_FreeSelectionCouseTeachingMode join ditm in DictionaryItemRepository.GetList(x => x.DictionaryCode == typeof(CF_TeachingMode).Name) on fsctm.TeachingModeID equals ditm.Value into dditm from editm in dditm.DefaultIfEmpty() select new FreeSelectionCourseView { FreeSelectionCouseID = fsc.FreeSelectionCouseID, DepartmentID = fsc.DepartmentID, DepartmentName = fsc.CF_Department.Name, SchoolyearNumID = fsc.SchoolyearNumID, SchoolcodeID = fsc.SchoolcodeID, IsEnable = (bool)fsc.IsEnable, CoursematerialID = fsc.CoursematerialID, TeachingModeName=editm.Name }; return query; } public IQueryable GetTeachingModeType(Expression> exp) { var query = from fsc in FreeSelectionCouseRepository.GetList(exp) from fsctm in fsc.EM_FreeSelectionCouseTeachingMode join ditm in DictionaryItemRepository.GetList(x => x.DictionaryCode == typeof(CF_TeachingMode).Name) on fsctm.TeachingModeID equals ditm.Value into dditm from editm in dditm.DefaultIfEmpty() select editm; return query; } } }