ArrangementDAL.cs 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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.CalendarManage;
  7. using System.Linq.Expressions;
  8. using EMIS.Entities;
  9. using EMIS.ViewModel;
  10. namespace EMIS.DataLogic.Common.CalendarManage
  11. {
  12. public class ArrangementDAL
  13. {
  14. public ArrangementsRepository ArrangementsRepository { get; set; }
  15. public CoursesTimeRepository coursesTimeRepository { get; set; }
  16. public DictionaryItemRepository dictionaryItemRepository { get; set; }
  17. public IQueryable<ArrangementView> GetArrangementView(Expression<Func<CF_Arrangements, bool>> exp)
  18. {
  19. var sql = (from a in ArrangementsRepository.GetList(exp)
  20. select new ArrangementView
  21. {
  22. ArrangementsID = a.ArrangementsID,
  23. CoursesTimeID = a.CoursesTimeID,
  24. StartTimes = a.EM_CoursesTime.StartTimes,
  25. EndTimes = a.EM_CoursesTime.EndTimes,
  26. TimesSegment = a.EM_CoursesTime.TimesSegment,
  27. StartHour = a.EM_CoursesTime.StartHour,
  28. EndHour = a.EM_CoursesTime.EndHour,
  29. StartMinutes = a.EM_CoursesTime.StartMinutes,
  30. EndMinutes = a.EM_CoursesTime.EndMinutes,
  31. Weekday = a.Weekday,
  32. IsOnWork = a.IsOnWork,
  33. RecordStatus = a.RecordStatus,
  34. CreateTime = a.CreateTime,
  35. CreateUserID = a.CreateUserID,
  36. ModifyTime = a.ModifyTime,
  37. ModifyUserID = a.ModifyUserID
  38. });
  39. return sql;
  40. }
  41. public IQueryable<ArrangementView> GetArrangementViewQueryable()
  42. {
  43. var query = from a in coursesTimeRepository.GetList(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE)
  44. select new ArrangementView
  45. {
  46. CoursesTimeID = a.CoursesTimeID,
  47. StartTimes = a.StartTimes,
  48. EndTimes = a.EndTimes,
  49. TimesSegment = a.TimesSegment,
  50. StartHour = a.StartHour,
  51. StartMinutes = a.StartMinutes,
  52. EndHour = a.EndHour,
  53. EndMinutes = a.EndMinutes,
  54. CreateTime = a.CreateTime,
  55. CreateUserID = a.CreateUserID,
  56. MondayIsOnWork = a.CF_Arrangements.Where(x => x.Weekday == (int)DayOfWeek.Monday).FirstOrDefault() == null ? false : a.CF_Arrangements.Where(x => x.Weekday == (int)DayOfWeek.Monday).FirstOrDefault().IsOnWork,
  57. TuesdayIsOnWork = a.CF_Arrangements.Where(x => x.Weekday == (int)DayOfWeek.Tuesday).FirstOrDefault() == null ? false : a.CF_Arrangements.Where(x => x.Weekday == (int)DayOfWeek.Tuesday).FirstOrDefault().IsOnWork,
  58. WednesdayIsOnWork = a.CF_Arrangements.Where(x => x.Weekday == (int)DayOfWeek.Wednesday).FirstOrDefault() == null ? false : a.CF_Arrangements.Where(x => x.Weekday == (int)DayOfWeek.Wednesday).FirstOrDefault().IsOnWork,
  59. ThursdayIsOnWork = a.CF_Arrangements.Where(x => x.Weekday == (int)DayOfWeek.Thursday).FirstOrDefault() == null ? false : a.CF_Arrangements.Where(x => x.Weekday == (int)DayOfWeek.Thursday).FirstOrDefault().IsOnWork,
  60. FridayIsOnWork = a.CF_Arrangements.Where(x => x.Weekday == (int)DayOfWeek.Friday).FirstOrDefault() == null ? false : a.CF_Arrangements.Where(x => x.Weekday == (int)DayOfWeek.Friday).FirstOrDefault().IsOnWork,
  61. SaturdayIsOnWork = a.CF_Arrangements.Where(x => x.Weekday == (int)DayOfWeek.Saturday).FirstOrDefault() == null ? false : a.CF_Arrangements.Where(x => x.Weekday == (int)DayOfWeek.Saturday).FirstOrDefault().IsOnWork,
  62. SundayIsOnWork = a.CF_Arrangements.Where(x => x.Weekday == (int)DayOfWeek.Sunday).FirstOrDefault() == null ? false : a.CF_Arrangements.Where(x => x.Weekday == (int)DayOfWeek.Sunday).FirstOrDefault().IsOnWork
  63. };
  64. return query;
  65. }
  66. }
  67. }