FreeSelectionCourseDAL.cs 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using EMIS.DataLogic.Repositories;
  6. using EMIS.DataLogic.Common.Cultureplan;
  7. using EMIS.ViewModel.SelectCourse;
  8. using System.Linq.Expressions;
  9. using EMIS.Entities;
  10. using EMIS.ViewModel;
  11. namespace EMIS.DataLogic.SelectCourse
  12. {
  13. public class FreeSelectionCourseDAL
  14. {
  15. public FreeSelectionCouseRepository FreeSelectionCouseRepository { get; set; }
  16. public FreeSelectionCouseTeachingSettingRepository FreeSelectionCouseTeachingSettingRepository { get; set; }
  17. public Lazy<CoursematerialDAL> CoursematerialDAL { get; set; }
  18. public DictionaryItemRepository DictionaryItemRepository { get; set; }
  19. public IQueryable<FreeSelectionCourseView> GetFreeSelectionCourseViewQueryable(Expression<Func<EM_FreeSelectionCouse, bool>> exp)
  20. {
  21. var query = from fsc in FreeSelectionCouseRepository.GetList(exp)
  22. join fscts in FreeSelectionCouseTeachingSettingRepository.Entities on fsc.FreeSelectionCouseID equals fscts.FreeSelectionCouseID
  23. join cm in CoursematerialDAL.Value.GetCoursematerialViewQueryable(x => true)
  24. on fsc.CoursematerialID equals cm.CoursematerialID
  25. join dicc in DictionaryItemRepository.GetList(x => x.DictionaryCode == typeof(CF_CourseCategory).Name)
  26. on fsc.CourseCategoryID equals dicc.Value into ddicc
  27. from edicc in ddicc.DefaultIfEmpty()
  28. join dict in DictionaryItemRepository.GetList(x => x.DictionaryCode == typeof(CF_CourseType).Name)
  29. on fsc.CourseTypeID equals dict.Value into ddict
  30. from edict in ddict.DefaultIfEmpty()
  31. join dicq in DictionaryItemRepository.GetList(x => x.DictionaryCode == typeof(CF_CourseQuality).Name)
  32. on fsc.CourseQualityID equals dicq.Value into ddicq
  33. from edicq in ddicq.DefaultIfEmpty()
  34. join dics in DictionaryItemRepository.GetList(x => x.DictionaryCode == typeof(CF_CourseStructure).Name)
  35. on fsc.CourseStructureID equals dics.Value into ddics
  36. from edics in ddics.DefaultIfEmpty()
  37. join disyn in DictionaryItemRepository.GetList(x => x.DictionaryCode == typeof(CF_SchoolyearNum).Name)
  38. on fsc.SchoolyearNumID equals disyn.Value into ddisyn
  39. from edisyn in ddisyn.DefaultIfEmpty()
  40. join disc in DictionaryItemRepository.GetList(x => x.DictionaryCode == typeof(CF_Semester).Name)
  41. on fsc.SchoolcodeID equals disc.Value into ddisc
  42. from edisc in ddisc.DefaultIfEmpty()
  43. //join dist in DictionaryItemRepository.GetList(x => x.DictionaryCode == typeof(CF_Startterm).Name)
  44. // on fsc.StarttermID equals dist.Value into ddist
  45. //from edist in ddist.DefaultIfEmpty()
  46. join diem in DictionaryItemRepository.GetList(x => x.DictionaryCode == typeof(CF_ExaminationMode).Name)
  47. on fsc.ExaminationModeID equals diem.Value into ddiem
  48. from ediem in ddiem.DefaultIfEmpty()
  49. join ditl in DictionaryItemRepository.GetList(x => x.DictionaryCode == typeof(CF_Teachinglanguage).Name)
  50. on fsc.TeachinglanguageID equals ditl.Value into dditl
  51. from editl in dditl.DefaultIfEmpty()
  52. select new FreeSelectionCourseView
  53. {
  54. FreeSelectionCouseID = fsc.FreeSelectionCouseID,
  55. //No = fsc.No,
  56. CollegeID = fsc.CF_Department.CollegeID,
  57. DepartmentID = fsc.DepartmentID,
  58. DepartmentName = fsc.CF_Department.Name,
  59. CourseStructureID = fsc.CourseStructureID,
  60. CourseStructureName = edics.Name,
  61. CourseCategoryID = fsc.CourseCategoryID,
  62. CourseCategoryName = edicc.Name,
  63. CourseTypeID = fsc.CourseTypeID,
  64. CourseTypeName = edict.Name,
  65. CourseQualityID = fsc.CourseQualityID,
  66. CourseQualityName = edicq.Name,
  67. ExaminationModeID = fsc.ExaminationModeID,
  68. ExaminationModeName = ediem.Name,
  69. TeachinglanguageID = fsc.TeachinglanguageID,
  70. TeachinglanguageName = editl.Name,
  71. SchoolyearNumID = fsc.SchoolyearNumID,
  72. SchoolyearNumName = edisyn.Name,
  73. SchoolcodeID = fsc.SchoolcodeID,
  74. SchoolcodeName = edisc.Name,
  75. PracticeTypeID=fsc.PracticeTypeID,
  76. //StarttermID = fsc.StarttermID,
  77. //StarttermName = edist.Name,
  78. IsEnable = (bool)fsc.IsEnable,
  79. Credit = fscts.Credit??0,
  80. TheoryCourse = fscts.TheoryCourse,
  81. Practicehours = fscts.Practicehours,
  82. Trialhours = fscts.Trialhours,
  83. Totalhours=((fscts.TheoryCourse ?? 0) + (fscts.Practicehours ?? 0) + (fscts.Trialhours ?? 0)),
  84. WeeklyHours = fscts.WeeklyHours,
  85. WeeklyNum = fscts.WeeklyNum,
  86. TheoryWeeklyNum = fscts.TheoryWeeklyNum,
  87. PracticeWeeklyNum = fscts.PracticeWeeklyNum,
  88. TrialWeeklyNum = fscts.TrialWeeklyNum,
  89. StartWeeklyNum = fscts.StartWeeklyNum,
  90. EndWeeklyNum = fscts.EndWeeklyNum,
  91. CoursematerialID = cm.CoursematerialID,
  92. CourseCode = cm.CourseCode,
  93. CourseName = cm.CourseName,
  94. CreateTime = fsc.CreateTime,
  95. CreateUserID = fsc.CreateUserID,
  96. ResultTypeID=fsc.ResultTypeID,
  97. Remark = fsc.Remark
  98. };
  99. return query;
  100. }
  101. public IQueryable<FreeSelectionCourseView> GetTeachingModeTypeViewQueryable(Expression<Func<EM_FreeSelectionCouse, bool>> exp)
  102. {
  103. var query = from fsc in FreeSelectionCouseRepository.GetList(exp)
  104. from fsctm in fsc.EM_FreeSelectionCouseTeachingMode
  105. join ditm in DictionaryItemRepository.GetList(x => x.DictionaryCode == typeof(CF_TeachingMode).Name)
  106. on fsctm.TeachingModeID equals ditm.Value
  107. into dditm
  108. from editm in dditm.DefaultIfEmpty()
  109. select new FreeSelectionCourseView
  110. {
  111. FreeSelectionCouseID = fsc.FreeSelectionCouseID,
  112. DepartmentID = fsc.DepartmentID,
  113. DepartmentName = fsc.CF_Department.Name,
  114. SchoolyearNumID = fsc.SchoolyearNumID,
  115. SchoolcodeID = fsc.SchoolcodeID,
  116. IsEnable = (bool)fsc.IsEnable,
  117. CoursematerialID = fsc.CoursematerialID,
  118. TeachingModeName=editm.Name
  119. };
  120. return query;
  121. }
  122. public IQueryable<Sys_DictionaryItem> GetTeachingModeType(Expression<Func<EM_FreeSelectionCouse, bool>> exp)
  123. {
  124. var query = from fsc in FreeSelectionCouseRepository.GetList(exp)
  125. from fsctm in fsc.EM_FreeSelectionCouseTeachingMode
  126. join ditm in DictionaryItemRepository.GetList(x => x.DictionaryCode == typeof(CF_TeachingMode).Name)
  127. on fsctm.TeachingModeID equals ditm.Value
  128. into dditm
  129. from editm in dditm.DefaultIfEmpty()
  130. select editm;
  131. return query;
  132. }
  133. }
  134. }