CollegeScheduleDAL.cs 1.7 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;
  7. using EMIS.DataLogic.UniversityManage.AdministrativeOrgan;
  8. using EMIS.DataLogic.Common.CalendarManage;
  9. using EMIS.ViewModel.UniversityManage.AdministrativeOrgan;
  10. namespace EMIS.DataLogic.EducationSchedule
  11. {
  12. public class CollegeScheduleDAL
  13. {
  14. public CollegePriorityRepository CollegePriorityRepository { get; set; }
  15. public CollegeScheduleStatusRepository CollegeScheduleStatusRepository { get; set; }
  16. public EducationSchedulingRepository EducationSchedulingRepository { get; set; }
  17. public SchoolyearRepository SchoolyearRepository { get; set; }
  18. public Lazy<CollegeDAL> CollegeDAL { get; set; }
  19. public IQueryable<CollegeView> GetCollegeViewByTime(DateTime scheduleDate)
  20. {
  21. var currentSchoolyear = SchoolyearRepository.GetSingle(x => x.IsCurrent == true);
  22. scheduleDate = scheduleDate.Date;
  23. var sql = (from cp in CollegePriorityRepository.GetList(x => x.StartDate <= scheduleDate && x.EndDate >= scheduleDate)
  24. join c in CollegeDAL.Value.GetCollegeViewQueryable(x => true) on cp.CollegeID equals c.CollegeID
  25. join css in CollegeScheduleStatusRepository.GetList(x => x.RecordStatus != (int)ES_CollegeScheduleStatusCode.Submited)
  26. on new { cp.CollegeID, SchoolyearID = (Guid?)currentSchoolyear.SchoolyearID } equals new { css.CollegeID, css.SchoolyearID }
  27. orderby cp.Priority descending
  28. select c
  29. ).Distinct();
  30. return sql;
  31. }
  32. }
  33. }