ExaminationSuspensionDAL.cs 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Linq.Expressions;
  6. using EMIS.DataLogic.Repositories;
  7. using EMIS.ViewModel.ScoreManage;
  8. using EMIS.Entities;
  9. using EMIS.ViewModel;
  10. namespace EMIS.DataLogic.ScoreManage
  11. {
  12. public class ExaminationSuspensionDAL
  13. {
  14. public SchoolyearRepository SchoolyearRepository { get; set; }
  15. public StudentRepository StudentRepository { get; set; }
  16. public FinalExaminationRepository FinalExaminationRepository { get; set; }
  17. public FinalExaminationStudentRepository FinalExaminationStudentRepository { get; set; }
  18. public CoursematerialRepository CoursematerialRepository { get; set; }
  19. public ExaminationSuspensionRepository ExaminationSuspensionRepository { get; set; }
  20. public EducationMissionRepository EducationMissionRepository { get; set; }
  21. public EducationMissionClassRepository EducationMissionClassRepository { get; set; }
  22. public IQueryable<ExaminationSuspensionView> GetExaminationSuspensionViewQueryable(Expression<Func<ER_ExaminationSuspension, bool>> exp)
  23. {
  24. var query = (from ms in ExaminationSuspensionRepository.GetList(exp)
  25. select new ExaminationSuspensionView
  26. {
  27. ExaminationSuspensionID = ms.ExaminationSuspensionID,
  28. UserID = ms.UserID,
  29. LoginID = ms.CF_Student.Sys_User.LoginID,
  30. Name = ms.CF_Student.Sys_User.Name,
  31. ClassmajorName = ms.CF_Student.CF_Classmajor.Name,
  32. CollegeID = ms.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.CollegeID,
  33. Year = ms.CF_Student.CF_Classmajor.CF_Grademajor.GradeID,
  34. StandardID = ms.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.StandardID,
  35. SchoolyearID = ms.SchoolyearID,
  36. SchoolyearCode = ms.CF_Schoolyear.Code,
  37. CoursematerialID = ms.CoursematerialID,
  38. CourseCode = ms.EM_Coursematerial.CourseCode,
  39. CourseName = ms.EM_Coursematerial.CourseName,
  40. ExamsCategoryID = ms.ExamsCategoryID,
  41. Reason = ms.Reason,
  42. RecordStatus = ms.RecordStatus,
  43. CreateTime = ms.CreateTime
  44. });
  45. return query;
  46. }
  47. public IQueryable<ExaminationSuspensionCoursematerialView> GetExaminationSuspensionCoursematerialViewQueryable(
  48. Expression<Func<EMIS.Entities.CF_Schoolyear, bool>> schoolyearExp, Expression<Func<CF_Student, bool>> studentExp)
  49. {
  50. List<int?> approvedFinalExaminationState = new List<int?> { (int)CF_ScoreState.Approved, (int)CF_ScoreState.Submitted };
  51. var query = (
  52. from emc in EducationMissionClassRepository.Entities
  53. join em in EducationMissionRepository.Entities on emc.EducationMissionID equals em.EducationMissionID
  54. join sy in SchoolyearRepository.GetList(schoolyearExp) on em.SchoolyearID equals sy.SchoolyearID
  55. join course in CoursematerialRepository.Entities on emc.CoursematerialID equals course.CoursematerialID
  56. from esc in emc.EM_EducationSchedulingClass
  57. from esccs in esc.CF_Student
  58. join s in StudentRepository.GetList(studentExp) on esccs.UserID equals s.UserID
  59. group emc by new ExaminationSuspensionCoursematerialView
  60. {
  61. CoursematerialID = course.CoursematerialID,
  62. CourseCode = course.CourseCode,
  63. CourseName = course.CourseName
  64. } into g
  65. select g.Key
  66. ).Union(
  67. from fe in FinalExaminationRepository.Entities
  68. join cm in CoursematerialRepository.Entities on fe.CoursematerialID equals cm.CoursematerialID
  69. join sy in SchoolyearRepository.GetList(schoolyearExp) on fe.SchoolyearID equals sy.SchoolyearID
  70. from fes in fe.ER_FinalExaminationStudent
  71. join s in StudentRepository.GetList(studentExp) on fes.UserID equals s.UserID
  72. group fe by new ExaminationSuspensionCoursematerialView {
  73. CoursematerialID = cm.CoursematerialID,
  74. CourseCode = cm.CourseCode,
  75. CourseName = cm.CourseName
  76. } into g
  77. select g.Key
  78. );
  79. return query.Distinct();
  80. }
  81. }
  82. }