SupEvaluationDAL.cs 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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.SupervisionManage;
  7. using System.Linq.Expressions;
  8. using EMIS.Entities;
  9. namespace EMIS.DataLogic.SupervisionManage
  10. {
  11. public class SupEvaluationDAL
  12. {
  13. public LessonRecordRepository LessonRecordRepository { get; set; }
  14. public ProjectRecordRepository ProjectRecordRepository { get; set; }
  15. public SchoolyearRepository SchoolyearRepository { get; set; }
  16. public SupervisionCollegeRepository SupervisionCollegeRepository { get; set; }
  17. public UserRepository UserRepository { get; set; }
  18. public CoursematerialRepository CoursematerialRepository { get; set; }
  19. public CoursesTimeRepository CoursesTimeRepository { get; set; }
  20. public StaffRepository StaffRepository { get; set; }
  21. public IQueryable<SupEvaluationView> GetSupEvaluationViewQueryable(Expression<Func<SUP_LessonRecord, bool>> exp,
  22. Expression<Func<SUP_ProjectRecord, bool>> ProjectRecordExp,Expression<Func<CF_Staff, bool>> supervisorExp)
  23. {
  24. var query =
  25. (
  26. from record in LessonRecordRepository.GetList(exp)
  27. from schoolyear in SchoolyearRepository.Entities.Where(x => x.SchoolyearID == record.SchoolyearID)
  28. from college in SupervisionCollegeRepository.Entities.Where(x => x.SupervisionCollegeID == record.SupervisionCollegeID)
  29. from user in UserRepository.Entities.Where(x => x.UserID == record.UserID)
  30. from course in CoursematerialRepository.Entities.Where(x => x.CoursematerialID == record.CoursematerialID)
  31. from time in CoursesTimeRepository.Entities.Where(x => x.CoursesTimeID == record.CoursesTimeID)
  32. from creator in UserRepository.Entities.Where(x => x.UserID == record.CreateUserID)
  33. from staff in StaffRepository.Entities.Where(x => x.UserID == user.UserID).DefaultIfEmpty().Where(supervisorExp)
  34. select new SupEvaluationView
  35. {
  36. LessonRecordID=record.LessonRecordID,
  37. ProjectRecordID=null,
  38. SchoolYearID = record.SchoolyearID,
  39. SchoolyearCode = schoolyear.Code,
  40. LessonDate = record.LessonDate,
  41. Location = record.Location,
  42. SupervisionCollegeID = record.SupervisionCollegeID,
  43. SupervisionCollegeName = college.Name,
  44. UserID = record.UserID,
  45. UserName = user.Name,
  46. SupervisionTypeID=null,
  47. CoursematerialID = record.CoursematerialID,
  48. CourseName = course.CourseName,
  49. Weekday = record.Weekday,
  50. CoursesTimeID = record.CoursesTimeID,
  51. StartTimes = time.StartTimes,
  52. EndTimes = time.EndTimes,
  53. TotalScore = record.TotalScore,
  54. Content = record.Content,
  55. Advise = record.Record,
  56. CreateUserID = record.CreateUserID,
  57. CreateUserName = creator.Name
  58. }).Union(
  59. from precord in ProjectRecordRepository.GetList(ProjectRecordExp)
  60. from pschoolyear in SchoolyearRepository.Entities.Where(x => x.SchoolyearID == precord.SchoolyearID)
  61. from pcollege in SupervisionCollegeRepository.Entities.Where(x => x.SupervisionCollegeID == precord.SupervisionCollegeID)
  62. from puser in UserRepository.Entities.Where(x => x.UserID == precord.UserID)
  63. from pcourse in CoursematerialRepository.Entities.Where(x => x.CoursematerialID == precord.CoursematerialID)
  64. from ptime in CoursesTimeRepository.Entities.Where(x => x.CoursesTimeID == precord.CoursesTimeID)
  65. from pcreator in UserRepository.Entities.Where(x => x.UserID == precord.CreateUserID)
  66. from staff in StaffRepository.Entities.Where(x => x.UserID == puser.UserID).DefaultIfEmpty().Where(supervisorExp)
  67. select new SupEvaluationView
  68. {
  69. LessonRecordID = null,
  70. ProjectRecordID = precord.ProjectRecordID,
  71. SchoolYearID = precord.SchoolyearID,
  72. SchoolyearCode = pschoolyear.Code,
  73. LessonDate = precord.ProjectDate,
  74. Location = precord.Location,
  75. SupervisionCollegeID = precord.SupervisionCollegeID,
  76. SupervisionCollegeName = pcollege.Name,
  77. UserID = precord.UserID,
  78. UserName = puser.Name,
  79. SupervisionTypeID=precord.SupervisionTypeID,
  80. CoursematerialID = precord.CoursematerialID,
  81. CourseName = pcourse.CourseName,
  82. Weekday = precord.Weekday,
  83. CoursesTimeID = precord.CoursesTimeID,
  84. StartTimes = ptime.StartTimes,
  85. EndTimes = ptime.EndTimes,
  86. TotalScore = precord.TotalScore,
  87. Content = precord.Content,
  88. Advise = precord.Advise,
  89. CreateUserID = precord.CreateUserID,
  90. CreateUserName = pcreator.Name
  91. });
  92. return query;
  93. }
  94. }
  95. }