LevelSettingSubjectDAL.cs 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. using EMIS.DataLogic.Repositories;
  2. using EMIS.Entities;
  3. using EMIS.ViewModel.ExamManage;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Linq.Expressions;
  8. using System.Text;
  9. namespace EMIS.DataLogic.ExamManage
  10. {
  11. public class LevelSettingSubjectDAL
  12. {
  13. public LevelSettingRepository levelSettingRepository { get; set; }
  14. public ExaminationProjectRepository examinationProjectRepository { get; set; }
  15. public ExaminationTypeRepository examinationTypeRepository { get; set; }
  16. public LevelSettingSubjectRepository levelSettingSubjectRepository { get; set; }
  17. public DictionaryItemRepository dictionaryItemRepository { get; set; }
  18. public ProjectScoreRepository projectScoreRepository { get; set; }
  19. public ExaminationProjectSubjectRepository examinationProjectSubjectRepository { get; set; }
  20. public IQueryable<LevelSettingView> GetLevelSettingView(Expression<Func<EX_ExaminationProject, bool>> erexp)
  21. {
  22. var query = from level in levelSettingRepository.Entities
  23. from epr in examinationProjectRepository.Entities.Where(erexp).Where(x => x.ExaminationProjectID == level.ExaminationProjectID)
  24. from etr in examinationTypeRepository.Entities.Where(x => x.ExaminationTypeID == epr.ExaminationTypeID)
  25. select new LevelSettingView
  26. {
  27. LevelSettingID = level.LevelSettingID,
  28. LevelName = level.LevelName,
  29. ExaminationProjectID = level.ExaminationProjectID,
  30. ExaminationProjectName = epr.Name,
  31. ExaminationTypeID = epr.ExaminationTypeID,
  32. ExaminationTypeName = etr.Name,
  33. IsPassed = level.IsPassed,
  34. IsPassedEdit = level.IsPassed.Value,
  35. IsPassLine = level.IsPassLine,
  36. IsPassLineEdit = level.IsPassLine.Value,
  37. RecordStatus = level.RecordStatus,
  38. };
  39. return query;
  40. }
  41. public IQueryable<LevelSettingSubjectView> GetLevelSettingSubjectViewByLevelID(Guid? levelSettingID)
  42. {
  43. var query = from level in levelSettingRepository.Entities.Where(x => x.LevelSettingID == levelSettingID)
  44. from lssr in levelSettingSubjectRepository.Entities.Where(x => x.LevelSettingID == level.LevelSettingID)
  45. from epr in examinationProjectRepository.Entities.Where(x => x.ExaminationProjectID == level.ExaminationProjectID)
  46. from etr in examinationTypeRepository.Entities.Where(x => x.ExaminationTypeID == epr.ExaminationTypeID)
  47. select new LevelSettingSubjectView
  48. {
  49. LevelSettingID = level.LevelSettingID,
  50. ExaminationSubjectID = lssr.ExaminationSubjectID,
  51. PassScore = lssr.PassScore
  52. };
  53. return query;
  54. }
  55. public LevelSettingView GetLevelSettingSubjectView(Guid? levelSettingID)
  56. {
  57. var query = from level in levelSettingRepository.Entities.Where(x => x.LevelSettingID == levelSettingID)
  58. from epr in examinationProjectRepository.Entities.Where(x => x.ExaminationProjectID == level.ExaminationProjectID)
  59. from etr in examinationTypeRepository.Entities.Where(x => x.ExaminationTypeID == epr.ExaminationTypeID)
  60. select new LevelSettingView
  61. {
  62. LevelSettingID = level.LevelSettingID,
  63. LevelName = level.LevelName,
  64. ExaminationProjectID = level.ExaminationProjectID,
  65. ExaminationProjectName = epr.Name,
  66. ExaminationTypeID = epr.ExaminationTypeID,
  67. ExaminationTypeName = etr.Name,
  68. IsPassed = level.IsPassed,
  69. IsPassedEdit = level.IsPassed.Value,
  70. IsPassLine = level.IsPassLine,
  71. IsPassLineEdit = level.IsPassLine.Value,
  72. RecordStatus = level.RecordStatus,
  73. };
  74. return query.FirstOrDefault();
  75. }
  76. public IQueryable<LevelSettingSubjectView> GetLevelSettingSubjectViewByProjectID(Guid? examinationProjectID)
  77. {
  78. var query = from dic in dictionaryItemRepository.Entities.Where(x => x.DictionaryCode == "EX_ExaminationSubject")
  79. select new LevelSettingSubjectView
  80. {
  81. ExaminationSubjectID = dic.Value,
  82. };
  83. if (examinationProjectID.HasValue)
  84. {
  85. query = from level in levelSettingRepository.Entities.Where(x => x.ExaminationProjectID == examinationProjectID)
  86. from lssr in levelSettingSubjectRepository.Entities.Where(x => x.LevelSettingID == level.LevelSettingID)
  87. select new LevelSettingSubjectView
  88. {
  89. LevelSettingID = level.LevelSettingID,
  90. ExaminationSubjectID = lssr.ExaminationSubjectID,
  91. PassScore = lssr.PassScore
  92. };
  93. }
  94. return query.Distinct();
  95. }
  96. }
  97. }