using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EMIS.DataLogic.Repositories;
using EMIS.ViewModel.SchedulingManage.SchedulingSettings;
using System.Linq.Expressions;
using EMIS.Entities;
using EMIS.ViewModel.CalendarManage;
using EMIS.ViewModel;
namespace EMIS.DataLogic.SchedulingManage.SchedulingSettings
{
public class ClassroomScheduleSettingDAL
{
public ClassroomScheduleSettingRepository classroomScheduleSettingRepository { get; set; }
public DictionaryItemRepository dictionaryItemRepository { get; set; }
public CoursesTimeRepository coursesTimeRepository { get; set; }
public ClassroomRepository classroomRepository { get; set; }
///
/// 查询教室可排时间设置
///
///
///
public IQueryable GetClassroomScheduleSettingViewQueryable(Expression> exp)
{
var query = from a in classroomRepository.GetList(exp)
select new ClassroomScheduleSettingView
{
ClassroomID = a.ClassroomID,
ClassroomCode = a.Code,
ClassroomName = a.Name,
CollegeName = a.CF_College.Name,
Totalseating = a.Totalseating,
Effectiveseating = a.Effectiveseating,
CreateUserID = a.CreateUserID,
CreateTime = a.CreateTime
};
return query;
}
///
/// 教室可排时间设置
///
/// 教室ID
///
public IQueryable GetArrangementViewQueryable(Guid? classroomID)
{
var query = from a in coursesTimeRepository.GetList(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE)
join b in
classroomScheduleSettingRepository.GetList(x => x.ClassroomID == classroomID)
on a.CoursesTimeID equals b.CoursesTimeID
group a by new
{
CoursesTimeID = a.CoursesTimeID,
StartTimes = a.StartTimes,
EndTimes = a.EndTimes,
TimesSegment = a.TimesSegment,
StartHour = a.StartHour,
StartMinutes = a.StartMinutes,
EndHour = a.EndHour,
EndMinutes = a.EndMinutes,
CreateTime = a.CreateTime,
CreateUserID = a.CreateUserID,
MondayIsOnWork = a.ES_ClassroomScheduleSetting.Where(x => x.Weekday == (int)DayOfWeek.Monday && x.ClassroomID == b.ClassroomID).FirstOrDefault().IsOnWork,
TuesdayIsOnWork = a.ES_ClassroomScheduleSetting.Where(x => x.Weekday == (int)DayOfWeek.Tuesday && x.ClassroomID == b.ClassroomID).FirstOrDefault().IsOnWork,
WednesdayIsOnWork = a.ES_ClassroomScheduleSetting.Where(x => x.Weekday == (int)DayOfWeek.Wednesday && x.ClassroomID == b.ClassroomID).FirstOrDefault().IsOnWork,
ThursdayIsOnWork = a.ES_ClassroomScheduleSetting.Where(x => x.Weekday == (int)DayOfWeek.Thursday && x.ClassroomID == b.ClassroomID).FirstOrDefault().IsOnWork,
FridayIsOnWork = a.ES_ClassroomScheduleSetting.Where(x => x.Weekday == (int)DayOfWeek.Friday && x.ClassroomID == b.ClassroomID).FirstOrDefault().IsOnWork,
SaturdayIsOnWork = a.ES_ClassroomScheduleSetting.Where(x => x.Weekday == (int)DayOfWeek.Saturday && x.ClassroomID == b.ClassroomID).FirstOrDefault().IsOnWork,
SundayIsOnWork = a.ES_ClassroomScheduleSetting.Where(x => x.Weekday == (int)DayOfWeek.Sunday && x.ClassroomID == b.ClassroomID).FirstOrDefault().IsOnWork
} into g
select new ArrangementView
{
CoursesTimeID = g.Key.CoursesTimeID,
StartTimes = g.Key.StartTimes,
EndTimes = g.Key.EndTimes,
TimesSegment = g.Key.TimesSegment,
StartHour = g.Key.StartHour,
StartMinutes = g.Key.StartMinutes,
EndHour = g.Key.EndHour,
EndMinutes = g.Key.EndMinutes,
CreateTime = g.Key.CreateTime,
CreateUserID = g.Key.CreateUserID,
MondayIsOnWork = g.Key.MondayIsOnWork,
TuesdayIsOnWork = g.Key.TuesdayIsOnWork,
WednesdayIsOnWork = g.Key.WednesdayIsOnWork,
ThursdayIsOnWork = g.Key.ThursdayIsOnWork,
FridayIsOnWork = g.Key.FridayIsOnWork,
SaturdayIsOnWork = g.Key.SaturdayIsOnWork,
SundayIsOnWork = g.Key.SundayIsOnWork,
};
return query;
}
}
}