using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using EMIS.Entities;
using EMIS.ViewModel;
using EMIS.ViewModel.CultureplanManage.CourseMaterial;
using EMIS.DataLogic.Repositories;
namespace EMIS.DataLogic.CultureplanManage.CourseMaterial
{
public class TeachTypeDAL
{
public ClassGroupingRepository ClassGroupingRepository { get; set; }
public ClassGroupingSettingsRepository ClassGroupingSettingsRepository { get; set; }
public DictionaryItemRepository DictionaryItemRepository { get; set; }
///
/// 查询对应的上课类型信息TeachTypeView
///
///
///
public IQueryable GetTeachTypeViewQueryable(Expression> exp)
{
var query = from cg in ClassGroupingRepository.GetList(exp)
select new TeachTypeView
{
ClassGroupingID = cg.ClassGroupingID,
ClassName = cg.ClassName,
TeachingModeIDList = cg.EM_ClassGroupingSettings.Select(x => x.TeachingModeID).ToList(),
Remark = cg.Remark,
RecordStatus = cg.RecordStatus,
CreateUserID = cg.CreateUserID,
CreateTime = cg.CreateTime,
ModifyUserID = cg.ModifyUserID,
ModifyTime = cg.ModifyTime
};
return query;
}
///
/// 查询对应的上课类型分班明细信息TeachTypeSettingView(根据主表)
///
///
///
public IQueryable GetTeachTypeSettingViewQueryable(Expression> exp)
{
var query = from dic in DictionaryItemRepository.GetList(x => x.DictionaryCode == typeof(CF_TeachingMode).Name)
join cgs in
(
from cg in ClassGroupingRepository.GetList(exp)
join cgs in ClassGroupingSettingsRepository.Entities
on cg.ClassGroupingID equals cgs.ClassGroupingID
select new
{
ClassGroupingSettingsID = cgs.ClassGroupingSettingsID,
ClassGroupingID = cgs.ClassGroupingID,
ClassName = cg.ClassName,
TeachingModeID = cgs.TeachingModeID,
RecordStatus = cgs.RecordStatus
}
)
on dic.Value equals cgs.TeachingModeID into tempcgs
from diccgs in tempcgs.DefaultIfEmpty()
select new TeachTypeSettingView
{
ClassGroupingSettingsID = diccgs.ClassGroupingSettingsID == null ? Guid.Empty : diccgs.ClassGroupingSettingsID,
ClassGroupingID = diccgs.ClassGroupingID,
ClassName = diccgs.ClassName,
TeachingModeID = dic.Value,
IsDivide = diccgs.ClassGroupingSettingsID == null ? false : true,
IsDisplay = dic.RecordStatus > (int)SYS_STATUS.UNUSABLE ? true : false,
RecordStatus = diccgs.RecordStatus
};
return query;
}
}
}