ScoreParameterCollegeSettingDAL.cs 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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.ScoreManage;
  7. using System.Linq.Expressions;
  8. using EMIS.Entities;
  9. using EMIS.ViewModel;
  10. namespace EMIS.DataLogic.ScoreManage
  11. {
  12. public class ScoreParameterCollegeSettingDAL
  13. {
  14. public ScoreParameterCollegeSettingRepository ScoreParameterCollegeSettingRepository { get; set; }
  15. public ScoreParameterCollegeSettingDetailRepository ScoreParameterCollegeSettingDetailRepository { get; set; }
  16. public CollegeRepository CollegeRepository { get; set; }
  17. public DictionaryItemRepository DictionaryItemRepository { get; set; }
  18. public IQueryable<ScoreParameterCollegeSettingView> GetScoreParameterCollegeSettingViewQueryable(Expression<Func<ER_ScoreParameterCollegeSetting, bool>> exp)
  19. {
  20. var sql = (from setting in ScoreParameterCollegeSettingRepository.GetList(exp)
  21. join college in CollegeRepository.Entities on setting.CollegeID equals college.CollegeID into dcollege
  22. from college in dcollege.DefaultIfEmpty()
  23. select new ScoreParameterCollegeSettingView
  24. {
  25. ScoreParameterCollegeSettingID = setting.ScoreParameterCollegeSettingID,
  26. CollegeID = setting.CollegeID,
  27. CollegeNo = college.No,
  28. CollegeName = college.Name,
  29. Years = setting.Years,
  30. ScoreTypeID = setting.ScoreTypeID
  31. });
  32. return sql;
  33. }
  34. public IQueryable<ScoreParameterSettingView> GetScoreParameterSettingViewQueryable(Expression<Func<ER_ScoreParameterCollegeSettingDetail, bool>> exp)
  35. {
  36. var sql = (from detail in ScoreParameterCollegeSettingDetailRepository.GetList(exp)
  37. where detail.ExamsCategoryID == null && detail.CourseTypeID == null
  38. select new ScoreParameterSettingView
  39. {
  40. ExamsTypeID = null,
  41. ExamsTypeName = null,
  42. CourseTypeID = null,
  43. CourseTypeName = null,
  44. ScoreFormulaID = detail.ScoreFormulaID,
  45. IsTotalFormula = detail.IsTotalFormula ?? true,
  46. CreditFormulaID = detail.CreditFormulaID,
  47. IsCreditFormula = detail.IsCreditFormula ?? true,
  48. GradePointFormulaID = detail.GradePointFormulaID,
  49. IsGradePointFormula = detail.IsGradePointFormula ?? true,
  50. OrderNo = (detail.ExamsCategoryID ?? 0) * (detail.CourseTypeID ?? 0)
  51. }).Concat(
  52. from category in DictionaryItemRepository.GetList(x => x.DictionaryCode == DictionaryItem.CF_ExamsCategory.ToString())
  53. join detail in ScoreParameterCollegeSettingDetailRepository.GetList(exp)
  54. on new { ExamsCategoryID = category.Value, CourseTypeID = (int?)null }
  55. equals new { detail.ExamsCategoryID, detail.CourseTypeID } into ddetail
  56. from detail in ddetail.DefaultIfEmpty()
  57. select new ScoreParameterSettingView
  58. {
  59. ExamsTypeID = category.Value,
  60. ExamsTypeName = category.Name,
  61. CourseTypeID = null,
  62. CourseTypeName = null,
  63. ScoreFormulaID = detail.ScoreFormulaID,
  64. IsTotalFormula = detail.IsTotalFormula ?? true,
  65. CreditFormulaID = detail.CreditFormulaID,
  66. IsCreditFormula = detail.IsCreditFormula ?? true,
  67. GradePointFormulaID = detail.GradePointFormulaID,
  68. IsGradePointFormula = detail.IsGradePointFormula ?? true,
  69. OrderNo = (detail.ExamsCategoryID ?? 0) * (detail.CourseTypeID ?? 0)
  70. }
  71. ).Concat(
  72. from courseType in DictionaryItemRepository.GetList(x => x.DictionaryCode == DictionaryItem.CF_CourseType.ToString())
  73. join detail in ScoreParameterCollegeSettingDetailRepository.GetList(exp)
  74. on new { ExamsCategoryID = (int?)null, CourseTypeID = courseType.Value }
  75. equals new { detail.ExamsCategoryID, detail.CourseTypeID } into ddetail
  76. from detail in ddetail.DefaultIfEmpty()
  77. select new ScoreParameterSettingView
  78. {
  79. ExamsTypeID = null,
  80. ExamsTypeName = null,
  81. CourseTypeID = courseType.Value,
  82. CourseTypeName = courseType.Name,
  83. ScoreFormulaID = detail.ScoreFormulaID,
  84. IsTotalFormula = detail.IsTotalFormula ?? true,
  85. CreditFormulaID = detail.CreditFormulaID,
  86. IsCreditFormula = detail.IsCreditFormula ?? true,
  87. GradePointFormulaID = detail.GradePointFormulaID,
  88. IsGradePointFormula = detail.IsGradePointFormula ?? true,
  89. OrderNo = (detail.ExamsCategoryID ?? 0) * (detail.CourseTypeID ?? 0)
  90. }
  91. ).Concat(
  92. from category in DictionaryItemRepository.GetList(x => x.DictionaryCode == DictionaryItem.CF_ExamsCategory.ToString())
  93. join courseType in DictionaryItemRepository.GetList(x => x.DictionaryCode == DictionaryItem.CF_CourseType.ToString())
  94. on true equals true
  95. join detail in ScoreParameterCollegeSettingDetailRepository.GetList(exp)
  96. on new { ExamsCategoryID = category.Value, CourseTypeID = courseType.Value }
  97. equals new { detail.ExamsCategoryID, detail.CourseTypeID } into ddetail
  98. from detail in ddetail.DefaultIfEmpty()
  99. select new ScoreParameterSettingView
  100. {
  101. ExamsTypeID = category.Value,
  102. ExamsTypeName = category.Name,
  103. CourseTypeID = courseType.Value,
  104. CourseTypeName = courseType.Name,
  105. ScoreFormulaID = detail.ScoreFormulaID,
  106. IsTotalFormula = detail.IsTotalFormula ?? true,
  107. CreditFormulaID = detail.CreditFormulaID,
  108. IsCreditFormula = detail.IsCreditFormula ?? true,
  109. GradePointFormulaID = detail.GradePointFormulaID,
  110. IsGradePointFormula = detail.IsGradePointFormula ?? true,
  111. OrderNo = (detail.ExamsCategoryID ?? 0) * (detail.CourseTypeID ?? 0)
  112. });
  113. return sql;
  114. }
  115. }
  116. }