using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EMIS.DataLogic.Repositories;
using System.Linq.Expressions;
using EMIS.Entities;
using EMIS.ViewModel.CalendarManage;
using EMIS.ViewModel;
namespace EMIS.DataLogic.Common.CalendarManage
{
public class CoursesTimeDAL
{
public CoursesTimeRepository coursesTimeRepository { get; set; }
public DictionaryItemRepository dictionaryItemRepository { get; set; }
///
/// 读取课程时间信息
///
///
///
public IQueryable GetCoursesTimeQueryable(Expression> exp)
{
var query = from a in coursesTimeRepository.GetList(exp)
join c in dictionaryItemRepository.Entities on new { a.TimesSegment, DictionaryCode = "CF_TimesSegment" }
equals new { TimesSegment = c.Value.Value, c.DictionaryCode } into gbsta
from gicbsta in gbsta.DefaultIfEmpty()
select new CoursesTimeView
{
CoursesTimeID = a.CoursesTimeID,
StartTimes = a.StartTimes,
EndTimes = a.EndTimes,
TimesSegment = a.TimesSegment,
TimesSegmentName = gicbsta.Name,
StartHour = a.StartHour,
StartMinutes = a.StartMinutes,
EndHour = a.EndHour,
EndMinutes = a.EndMinutes,
CreateUserID = a.CreateUserID,
CreateTime = a.CreateTime,
ModifyUserID = a.ModifyUserID,
ModifyTime = a.ModifyTime
};
return query;
}
public IQueryable GetNextCoursesTimeQueryable(Expression> exp)
{
var query = from a in coursesTimeRepository.GetList(exp)
join nc in coursesTimeRepository.GetList(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE) on a.StartTimes + 1 equals nc.StartTimes
join c in dictionaryItemRepository.Entities on new { nc.TimesSegment, DictionaryCode = "CF_TimesSegment" }
equals new { TimesSegment = c.Value.Value, c.DictionaryCode } into gbsta
from gicbsta in gbsta.DefaultIfEmpty()
select new CoursesTimeView
{
CoursesTimeID = nc.CoursesTimeID,
StartTimes = a.StartTimes,
EndTimes = a.EndTimes,
TimesSegment = nc.TimesSegment,
TimesSegmentName = gicbsta.Name,
StartHour = nc.StartHour,
StartMinutes = nc.StartMinutes,
EndHour = nc.EndHour,
EndMinutes = nc.EndMinutes,
CreateUserID = nc.CreateUserID,
CreateTime = nc.CreateTime,
ModifyUserID = nc.ModifyUserID,
ModifyTime = nc.ModifyTime
};
return query;
}
}
}