TeacherScheduleDAL.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536
  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.EducationSchedule;
  7. using System.Linq.Expressions;
  8. using EMIS.Entities;
  9. namespace EMIS.DataLogic.EducationSchedule
  10. {
  11. public class TeacherScheduleDAL
  12. {
  13. public TeacherScheduleSettingRepository TeacherScheduleSettingRepository { get; set; }
  14. public EducationSchedulingRepository EducationSchedulingRepository { get; set; }
  15. public StaffRepository StaffRepository { get; set; }
  16. public IQueryable<TeacherWorkTimeView> GetTeacherWorkTimeView(Expression<Func<ES_EducationScheduling, bool>> schedulingExp,
  17. Expression<Func<CF_Staff, bool>> staffExp)
  18. {
  19. var q = (from es in EducationSchedulingRepository.GetList(schedulingExp)
  20. from s in es.ES_EducationSchedulingTeacher
  21. from eswn in es.ES_EducationSchedulingWeekNum.Where(x => x.WeekNum.HasValue)
  22. group es by new { s.CF_Staff.UserID, Name = s.CF_Staff.Sys_User.Name, WeekNum = eswn.WeekNum } into g
  23. select new TeacherWorkTimeView
  24. {
  25. UserID = g.Key.UserID,
  26. Name = g.Key.Name,
  27. WeekNum = g.Key.WeekNum ?? 0,
  28. WorkTime = g.Sum(x => (x.EM_CoursesTime.EndTimes != null && x.EM_CoursesTime.StartTimes != null) ? (x.EM_CoursesTime.EndTimes - x.EM_CoursesTime.StartTimes + 1) : 0)
  29. });
  30. return q;
  31. }
  32. }
  33. }