StudentPrintTimesDAL.cs 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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.TerminatePrinter;
  7. using System.Linq.Expressions;
  8. using EMIS.Entities;
  9. namespace EMIS.DataLogic.TerminatePrinter
  10. {
  11. public class StudentPrintTimesDAL
  12. {
  13. public StudentPrintTimesRepository StudentPrintTimesRepository { get; set; }
  14. public StudentRepository StudentRepository { get; set; }
  15. public ClassmajorRepository ClassmajorRepository { get; set; }
  16. public GrademajorRepository GrademajorRepository { get; set; }
  17. public FacultymajorRepository FacultymajorRepository { get; set; }
  18. public CollegeRepository CollegeRepository { get; set; }
  19. public UserRepository UserRepository { get; set; }
  20. public InSchoolSettingRepository InSchoolSettingRepository { get; set; }
  21. public PrintControlRepository PrintControlRepository { get; set; }
  22. public IQueryable<StudentPrintTimesView> GetStudentPrintTimesViewQueryable(Expression<Func<CF_Facultymajor, bool>> facultyExp,
  23. Expression<Func<CF_Grademajor, bool>> gradeExp,
  24. Expression<Func<CF_Classmajor, bool>> classExp)
  25. {
  26. var query = from times in StudentPrintTimesRepository.Entities
  27. from student in StudentRepository.Entities.Where(x => times.UserID == x.UserID)
  28. from user in UserRepository.Entities.Where(x => student.UserID == x.UserID)
  29. from classmajor in ClassmajorRepository.Entities.Where(classExp).Where(x => student.ClassmajorID == x.ClassmajorID)
  30. from grade in GrademajorRepository.Entities.Where(gradeExp).Where(x => classmajor.GrademajorID == x.GrademajorID)
  31. from faculty in FacultymajorRepository.Entities.Where(facultyExp).Where(x => grade.FacultymajorID == x.FacultymajorID)
  32. from college in CollegeRepository.Entities.Where(x => faculty.CollegeID == x.CollegeID)
  33. from inschool in InSchoolSettingRepository.Entities.Where(x => student.InSchoolStatusID == x.InSchoolStatusID)
  34. select new StudentPrintTimesView
  35. {
  36. StudentPrintTimesID = times.StudentPrintTimesID,
  37. CollegeID = college.CollegeID,
  38. CollegeNo = college.No,
  39. CollegeName = college.Name,
  40. YearID = grade.GradeID,
  41. StandardID = faculty.StandardID,
  42. ClassmajorID = classmajor.ClassmajorID,
  43. ClassmajorNo = classmajor.No,
  44. ClassmajorName = classmajor.Name,
  45. UserID = student.UserID,
  46. LoginID = user.LoginID,
  47. Name = user.Name,
  48. IsInSchool = inschool.IsSelected,
  49. Times = times.Times,
  50. RecordStatus = times.RecordStatus,
  51. CreateUserID = times.CreateUserID,
  52. CreateTime = times.CreateTime,
  53. ModifyUserID = times.ModifyUserID,
  54. ModifyTime = times.ModifyTime
  55. };
  56. return query;
  57. }
  58. public IQueryable<StudentPrintMessageView> GetStudentPrintMessageViewQueryable(Expression<Func<Sys_User, bool>> exp)
  59. {
  60. var query = (from user in UserRepository.GetList(exp)
  61. from student in StudentRepository.Entities.Where(x => user.UserID == x.UserID)
  62. from classmajor in ClassmajorRepository.Entities.Where(x => student.ClassmajorID == x.ClassmajorID)
  63. from grade in GrademajorRepository.Entities.Where(x => classmajor.GrademajorID == x.GrademajorID)
  64. from inschool in InSchoolSettingRepository.Entities.Where(x => student.InSchoolStatusID == x.InSchoolStatusID)
  65. .DefaultIfEmpty()
  66. from control in PrintControlRepository.Entities.Where(x => grade.GradeID == x.YearID)
  67. .DefaultIfEmpty()
  68. from times in StudentPrintTimesRepository.Entities.Where(x => user.UserID == x.UserID)
  69. .DefaultIfEmpty()
  70. select new StudentPrintMessageView
  71. {
  72. UserID = user.UserID,
  73. TotalPrintTimes = (inschool.IsSelected == true) ? (control.Times ?? 0) : 0,
  74. PrintTimes = (times.Times ?? 0)
  75. }
  76. );
  77. return query;
  78. }
  79. }
  80. }