ClassroomScheduleSettingDAL.cs 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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.SchedulingManage.SchedulingSettings;
  7. using System.Linq.Expressions;
  8. using EMIS.Entities;
  9. using EMIS.ViewModel.CalendarManage;
  10. using EMIS.ViewModel;
  11. namespace EMIS.DataLogic.SchedulingManage.SchedulingSettings
  12. {
  13. public class ClassroomScheduleSettingDAL
  14. {
  15. public ClassroomScheduleSettingRepository classroomScheduleSettingRepository { get; set; }
  16. public DictionaryItemRepository dictionaryItemRepository { get; set; }
  17. public CoursesTimeRepository coursesTimeRepository { get; set; }
  18. public ClassroomRepository classroomRepository { get; set; }
  19. /// <summary>
  20. /// 查询教室可排时间设置
  21. /// </summary>
  22. /// <param name="exp"></param>
  23. /// <returns></returns>
  24. public IQueryable<ClassroomScheduleSettingView> GetClassroomScheduleSettingViewQueryable(Expression<Func<CF_Classroom, bool>> exp)
  25. {
  26. var query = from a in classroomRepository.GetList(exp)
  27. select new ClassroomScheduleSettingView
  28. {
  29. ClassroomID = a.ClassroomID,
  30. ClassroomCode = a.Code,
  31. ClassroomName = a.Name,
  32. CollegeName = a.CF_College.Name,
  33. Totalseating = a.Totalseating,
  34. Effectiveseating = a.Effectiveseating,
  35. CreateUserID = a.CreateUserID,
  36. CreateTime = a.CreateTime
  37. };
  38. return query;
  39. }
  40. /// <summary>
  41. /// 教室可排时间设置
  42. /// </summary>
  43. /// <param name="classroomID">教室ID</param>
  44. /// <returns></returns>
  45. public IQueryable<ArrangementView> GetArrangementViewQueryable(Guid? classroomID)
  46. {
  47. var query = from a in coursesTimeRepository.GetList(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE)
  48. join b in
  49. classroomScheduleSettingRepository.GetList(x => x.ClassroomID == classroomID)
  50. on a.CoursesTimeID equals b.CoursesTimeID
  51. group a by new
  52. {
  53. CoursesTimeID = a.CoursesTimeID,
  54. StartTimes = a.StartTimes,
  55. EndTimes = a.EndTimes,
  56. TimesSegment = a.TimesSegment,
  57. StartHour = a.StartHour,
  58. StartMinutes = a.StartMinutes,
  59. EndHour = a.EndHour,
  60. EndMinutes = a.EndMinutes,
  61. CreateTime = a.CreateTime,
  62. CreateUserID = a.CreateUserID,
  63. MondayIsOnWork = a.ES_ClassroomScheduleSetting.Where(x => x.Weekday == (int)DayOfWeek.Monday && x.ClassroomID == b.ClassroomID).FirstOrDefault().IsOnWork,
  64. TuesdayIsOnWork = a.ES_ClassroomScheduleSetting.Where(x => x.Weekday == (int)DayOfWeek.Tuesday && x.ClassroomID == b.ClassroomID).FirstOrDefault().IsOnWork,
  65. WednesdayIsOnWork = a.ES_ClassroomScheduleSetting.Where(x => x.Weekday == (int)DayOfWeek.Wednesday && x.ClassroomID == b.ClassroomID).FirstOrDefault().IsOnWork,
  66. ThursdayIsOnWork = a.ES_ClassroomScheduleSetting.Where(x => x.Weekday == (int)DayOfWeek.Thursday && x.ClassroomID == b.ClassroomID).FirstOrDefault().IsOnWork,
  67. FridayIsOnWork = a.ES_ClassroomScheduleSetting.Where(x => x.Weekday == (int)DayOfWeek.Friday && x.ClassroomID == b.ClassroomID).FirstOrDefault().IsOnWork,
  68. SaturdayIsOnWork = a.ES_ClassroomScheduleSetting.Where(x => x.Weekday == (int)DayOfWeek.Saturday && x.ClassroomID == b.ClassroomID).FirstOrDefault().IsOnWork,
  69. SundayIsOnWork = a.ES_ClassroomScheduleSetting.Where(x => x.Weekday == (int)DayOfWeek.Sunday && x.ClassroomID == b.ClassroomID).FirstOrDefault().IsOnWork
  70. } into g
  71. select new ArrangementView
  72. {
  73. CoursesTimeID = g.Key.CoursesTimeID,
  74. StartTimes = g.Key.StartTimes,
  75. EndTimes = g.Key.EndTimes,
  76. TimesSegment = g.Key.TimesSegment,
  77. StartHour = g.Key.StartHour,
  78. StartMinutes = g.Key.StartMinutes,
  79. EndHour = g.Key.EndHour,
  80. EndMinutes = g.Key.EndMinutes,
  81. CreateTime = g.Key.CreateTime,
  82. CreateUserID = g.Key.CreateUserID,
  83. MondayIsOnWork = g.Key.MondayIsOnWork,
  84. TuesdayIsOnWork = g.Key.TuesdayIsOnWork,
  85. WednesdayIsOnWork = g.Key.WednesdayIsOnWork,
  86. ThursdayIsOnWork = g.Key.ThursdayIsOnWork,
  87. FridayIsOnWork = g.Key.FridayIsOnWork,
  88. SaturdayIsOnWork = g.Key.SaturdayIsOnWork,
  89. SundayIsOnWork = g.Key.SundayIsOnWork,
  90. };
  91. return query;
  92. }
  93. }
  94. }