GraduationCourseTypeSettingDAL.cs 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using EMIS.ViewModel.GraduationManage.GraduationRequirement;
  6. using System.Linq.Expressions;
  7. using EMIS.Entities;
  8. using EMIS.DataLogic.Repositories;
  9. using EMIS.ViewModel;
  10. namespace EMIS.DataLogic.GraduationManage.GraduationRequirement
  11. {
  12. public class GraduationCourseTypeSettingDAL
  13. {
  14. public GraduationCourseTypeSettingRepository GraduationCourseTypeSettingRepository { get; set; }
  15. public CourseTypeSelectCourseTypeRepository CourseTypeSelectCourseTypeRepository { get; set; }
  16. public DictionaryItemRepository DictionaryItemRepository { get; set; }
  17. /// <summary>
  18. /// 查询对应的毕业课程类型设定信息View(对应的字典表信息左连毕业课程类型设定表、课程类型选修设置表)
  19. /// </summary>
  20. /// <param name="exp"></param>
  21. /// <returns></returns>
  22. public IQueryable<GraduationCourseTypeSettingView> GetGraduationCourseTypeSettingQueryable(Expression<Func<ER_GraduationCourseTypeSetting, bool>> exp)
  23. {
  24. var query = from courseType in DictionaryItemRepository.GetList(x => x.DictionaryCode == typeof(CF_CourseType).Name)
  25. join cs in CourseTypeSelectCourseTypeRepository.Entities
  26. on courseType.Value equals cs.CourseTypeID
  27. into tempcs
  28. from csc in tempcs.DefaultIfEmpty()
  29. join gs in GraduationCourseTypeSettingRepository.GetList(exp)
  30. on courseType.Value equals gs.CourseTypeID
  31. into tempgs
  32. from gcs in tempgs.DefaultIfEmpty()
  33. select new GraduationCourseTypeSettingView
  34. {
  35. GraduationCourseTypeSettingID = gcs.GraduationCourseTypeSettingID == null ? Guid.Empty : gcs.GraduationCourseTypeSettingID,
  36. CourseTypeID = courseType.Value,
  37. CourseTypeName = courseType.Name,
  38. ColourBlock = "",
  39. CourseTypeColour = (csc.CourseTypeColour == null || csc.CourseTypeColour == "") ? "white" : csc.CourseTypeColour,
  40. IsRequired = csc.IsRequired == null ? false : csc.IsRequired,
  41. IsOptionalCourse = csc.IsOptionalCourse == null ? false : csc.IsOptionalCourse,
  42. IsFreeSelectionCourse = csc.IsFreeSelectionCourse == null ? false : csc.IsFreeSelectionCourse,
  43. IsElective = gcs.IsElective == null ? false : gcs.IsElective,
  44. IsElectivePublic = gcs.IsElectivePublic == null ? false : gcs.IsElectivePublic,
  45. IsGeneralEducation = gcs.IsGeneralEducation == null ? false : gcs.IsGeneralEducation,
  46. IsSchoolbasedCurriculum = gcs.IsSchoolbasedCurriculum == null ? false : gcs.IsSchoolbasedCurriculum,
  47. IsPractise = gcs.IsPractise == null ? false : gcs.IsPractise,
  48. IsDisplay = courseType.RecordStatus > (int)SYS_STATUS.UNUSABLE ? true : false,
  49. RecordStatus = gcs.RecordStatus,
  50. CreateUserID = gcs.CreateUserID,
  51. CreateTime = gcs.CreateTime,
  52. ModifyUserID = gcs.ModifyUserID,
  53. ModifyTime = gcs.ModifyTime
  54. };
  55. return query;
  56. }
  57. /// <summary>
  58. /// 查询对应的毕业课程类型设定信息View(设定表与对应的字典表信息内联)
  59. /// </summary>
  60. /// <param name="exp"></param>
  61. /// <returns></returns>
  62. public IQueryable<GraduationCourseTypeSettingView> GetGraduationCourseTypeSettingView(Expression<Func<ER_GraduationCourseTypeSetting, bool>> exp)
  63. {
  64. var query = from gcs in GraduationCourseTypeSettingRepository.GetList(exp)
  65. join courseType in DictionaryItemRepository.GetList(x => x.DictionaryCode == typeof(CF_CourseType).Name)
  66. on gcs.CourseTypeID equals courseType.Value
  67. select new GraduationCourseTypeSettingView
  68. {
  69. GraduationCourseTypeSettingID = gcs.GraduationCourseTypeSettingID,
  70. CourseTypeID = courseType.Value,
  71. CourseTypeName = courseType.Name,
  72. IsElective = gcs.IsElective,
  73. IsElectivePublic = gcs.IsElectivePublic,
  74. IsGeneralEducation = gcs.IsGeneralEducation,
  75. IsSchoolbasedCurriculum = gcs.IsSchoolbasedCurriculum,
  76. IsPractise = gcs.IsPractise,
  77. IsDisplay = courseType.RecordStatus > (int)SYS_STATUS.UNUSABLE ? true : false,
  78. RecordStatus = gcs.RecordStatus,
  79. CreateUserID = gcs.CreateUserID,
  80. CreateTime = gcs.CreateTime,
  81. ModifyUserID = gcs.ModifyUserID,
  82. ModifyTime = gcs.ModifyTime
  83. };
  84. return query;
  85. }
  86. }
  87. }