CourseTypeSetDAL.cs 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using EMIS.DataLogic.Repositories;
  6. using EMIS.ViewModel.CultureplanManage.CourseMaterial;
  7. using System.Linq.Expressions;
  8. using EMIS.Entities;
  9. using EMIS.ViewModel;
  10. namespace EMIS.DataLogic.CultureplanManage.CourseMaterial
  11. {
  12. public class CourseTypeSetDAL
  13. {
  14. public CourseTypeSelectCourseTypeRepository CourseTypeSelectCourseTypeRepository { get; set; }
  15. public DictionaryItemRepository DictionaryItemRepository { get; set; }
  16. public UserRepository UserRepository { get; set; }
  17. /// <summary>
  18. /// 查询对应的课程类型设定信息View(对应的字典表信息左连设定表)
  19. /// </summary>
  20. /// <param name="exp"></param>
  21. /// <returns></returns>
  22. public IQueryable<CourseTypeSetView> GetCourseTypeSetListView(Expression<Func<EM_CourseTypeSelectCourseType, bool>> exp)
  23. {
  24. var query = from courseType in DictionaryItemRepository.GetList(x => x.DictionaryCode == typeof(CF_CourseType).Name)
  25. join set in CourseTypeSelectCourseTypeRepository.GetList(exp)
  26. on courseType.Value equals set.CourseTypeID into tempcou
  27. from courseTypeSet in tempcou.DefaultIfEmpty()
  28. join usc in UserRepository.Entities
  29. on courseTypeSet.CreateUserID equals usc.UserID into tempusc
  30. from uscu in tempusc.DefaultIfEmpty()
  31. join usm in UserRepository.Entities
  32. on courseTypeSet.ModifyUserID equals usm.UserID into tempusm
  33. from usmu in tempusm.DefaultIfEmpty()
  34. select new CourseTypeSetView
  35. {
  36. CourseTypeSelectCourseTypeID = courseTypeSet.CourseTypeSelectCourseTypeID == null ? Guid.Empty : courseTypeSet.CourseTypeSelectCourseTypeID,
  37. CourseTypeID = courseType.Value,
  38. CourseTypeName = courseType.Name,
  39. ColourBlock = "",
  40. CourseTypeColour = (courseTypeSet.CourseTypeColour == null || courseTypeSet.CourseTypeColour == "") ? "white" : courseTypeSet.CourseTypeColour,
  41. IsRequired = courseTypeSet.IsRequired == null ? false : courseTypeSet.IsRequired,
  42. IsOptionalCourse = courseTypeSet.IsOptionalCourse == null ? false : courseTypeSet.IsOptionalCourse,
  43. IsFreeSelectionCourse = courseTypeSet.IsFreeSelectionCourse == null ? false : courseTypeSet.IsFreeSelectionCourse,
  44. IsDisplay = courseType.RecordStatus > (int)SYS_STATUS.UNUSABLE ? true : false,
  45. RecordStatus = courseTypeSet.RecordStatus,
  46. CreateUserID = courseTypeSet.CreateUserID,
  47. CreateUserName = uscu.Name,
  48. CreateTime = courseTypeSet.CreateTime,
  49. ModifyUserID = courseTypeSet.ModifyUserID,
  50. ModifyUserName = usmu.Name,
  51. ModifyTime = courseTypeSet.ModifyTime
  52. };
  53. return query;
  54. }
  55. /// <summary>
  56. /// 查询对应的课程类型设定信息View(设定表与对应的字典表信息内联)
  57. /// </summary>
  58. /// <param name="exp"></param>
  59. /// <returns></returns>
  60. public IQueryable<CourseTypeSetView> GetCourseTypeSelectCourseType(Expression<Func<EM_CourseTypeSelectCourseType, bool>> exp)
  61. {
  62. var query = from courseTypeSet in CourseTypeSelectCourseTypeRepository.GetList(exp)
  63. join courseType in DictionaryItemRepository.GetList(x => x.DictionaryCode == typeof(CF_CourseType).Name)
  64. on courseTypeSet.CourseTypeID equals courseType.Value
  65. join usc in UserRepository.Entities
  66. on courseTypeSet.CreateUserID equals usc.UserID into tempusc
  67. from uscu in tempusc.DefaultIfEmpty()
  68. join usm in UserRepository.Entities
  69. on courseTypeSet.ModifyUserID equals usm.UserID into tempusm
  70. from usmu in tempusm.DefaultIfEmpty()
  71. select new CourseTypeSetView
  72. {
  73. CourseTypeSelectCourseTypeID = courseTypeSet.CourseTypeSelectCourseTypeID,
  74. CourseTypeID = courseType.Value.Value,
  75. CourseTypeName = courseType.Name,
  76. ColourBlock = "",
  77. CourseTypeColour = (courseTypeSet.CourseTypeColour == null || courseTypeSet.CourseTypeColour == "") ? "white" : courseTypeSet.CourseTypeColour,
  78. IsRequired = courseTypeSet.IsRequired,
  79. IsOptionalCourse = courseTypeSet.IsOptionalCourse,
  80. IsFreeSelectionCourse = courseTypeSet.IsFreeSelectionCourse,
  81. IsDisplay = courseType.RecordStatus > (int)SYS_STATUS.UNUSABLE ? true : false,
  82. RecordStatus = courseTypeSet.RecordStatus,
  83. CreateUserID = courseTypeSet.CreateUserID,
  84. CreateUserName = uscu.Name,
  85. CreateTime = courseTypeSet.CreateTime,
  86. ModifyUserID = courseTypeSet.ModifyUserID,
  87. ModifyUserName = usmu.Name,
  88. ModifyTime = courseTypeSet.ModifyTime
  89. };
  90. return query;
  91. }
  92. }
  93. }