using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EMIS.DataLogic.Repositories;
using EMIS.ViewModel.SchedulingManage.SchedulingSettings;
using EMIS.Entities;
using System.Linq.Expressions;
using EMIS.ViewModel.CalendarManage;
using EMIS.ViewModel;
namespace EMIS.DataLogic.SchedulingManage.SchedulingSettings
{
public class ClassmajorScheduleSettingDAL
{
public ClassmajorScheduleSettingRepository classmajorScheduleSettingRepository { get; set; }
public DictionaryItemRepository dictionaryItemRepository { get; set; }
public CoursesTimeRepository coursesTimeRepository { get; set; }
public ClassmajorRepository classmajorRepository { get; set; }
///
///
///
///
public IQueryable GetClassmajorScheduleSettingViewQueryable(Expression> exp)
{
var query = from a in classmajorRepository.GetList(exp)
join b in dictionaryItemRepository.GetList(x => x.DictionaryCode == typeof(EMIS.ViewModel.CF_Education).Name)
on a.CF_Grademajor.CF_Facultymajor.EducationID equals b.Value
into ge
from gEducation in ge.DefaultIfEmpty()
join c in dictionaryItemRepository.GetList(x => x.DictionaryCode == typeof(EMIS.ViewModel.CF_Learningform).Name)
on a.CF_Grademajor.CF_Facultymajor.LearningformID equals c.Value
into glf
from gLearningform in glf.DefaultIfEmpty()
select new ClassmajorScheduleSettingView
{
ClassmajorID = a.ClassmajorID,
ClassmajorNo = a.No,
ClassmajorName = a.Name,
yearsID = a.CF_Grademajor.GradeID,
GrademajorName = a.CF_Grademajor.Name,
EducationName = gEducation.Name,
LearningformName = gLearningform.Name,
LearnSystem = a.CF_Grademajor.CF_Facultymajor.LearnSystem,
CollegeName = a.CF_Grademajor.CF_Facultymajor.CF_College.Name,
CreateUserID = a.CreateUserID,
CreateTime = a.CreateTime,
};
return query;
}
///
/// 教室可排时间设置
///
/// 教室ID
///
public IQueryable GetArrangementViewQueryable(Guid? classmajorID)
{
var query = from a in coursesTimeRepository.GetList(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE)
join b in
classmajorScheduleSettingRepository.GetList(x => x.ClassmajorID == classmajorID)
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_ClassmajorScheduleSetting.Where(x => x.Weekday == (int)DayOfWeek.Monday && x.ClassmajorID == b.ClassmajorID).FirstOrDefault().IsOnWork,
TuesdayIsOnWork = a.ES_ClassmajorScheduleSetting.Where(x => x.Weekday == (int)DayOfWeek.Tuesday && x.ClassmajorID == b.ClassmajorID).FirstOrDefault().IsOnWork,
WednesdayIsOnWork = a.ES_ClassmajorScheduleSetting.Where(x => x.Weekday == (int)DayOfWeek.Wednesday && x.ClassmajorID == b.ClassmajorID).FirstOrDefault().IsOnWork,
ThursdayIsOnWork = a.ES_ClassmajorScheduleSetting.Where(x => x.Weekday == (int)DayOfWeek.Thursday && x.ClassmajorID == b.ClassmajorID).FirstOrDefault().IsOnWork,
FridayIsOnWork = a.ES_ClassmajorScheduleSetting.Where(x => x.Weekday == (int)DayOfWeek.Friday && x.ClassmajorID == b.ClassmajorID).FirstOrDefault().IsOnWork,
SaturdayIsOnWork = a.ES_ClassmajorScheduleSetting.Where(x => x.Weekday == (int)DayOfWeek.Saturday && x.ClassmajorID == b.ClassmajorID).FirstOrDefault().IsOnWork,
SundayIsOnWork = a.ES_ClassmajorScheduleSetting.Where(x => x.Weekday == (int)DayOfWeek.Sunday && x.ClassmajorID == b.ClassmajorID).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;
}
}
}