using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EMIS.DataLogic.Repositories;
using EMIS.ViewModel.CultureplanManage.CourseMaterial;
using System.Linq.Expressions;
using EMIS.Entities;
using EMIS.ViewModel;
namespace EMIS.DataLogic.CultureplanManage.CourseMaterial
{
public class CourseTypeSetDAL
{
public CourseTypeSelectCourseTypeRepository CourseTypeSelectCourseTypeRepository { get; set; }
public DictionaryItemRepository DictionaryItemRepository { get; set; }
public UserRepository UserRepository { get; set; }
///
/// 查询对应的课程类型设定信息View(对应的字典表信息左连设定表)
///
///
///
public IQueryable GetCourseTypeSetListView(Expression> exp)
{
var query = from courseType in DictionaryItemRepository.GetList(x => x.DictionaryCode == typeof(CF_CourseType).Name)
join set in CourseTypeSelectCourseTypeRepository.GetList(exp)
on courseType.Value equals set.CourseTypeID into tempcou
from courseTypeSet in tempcou.DefaultIfEmpty()
join usc in UserRepository.Entities
on courseTypeSet.CreateUserID equals usc.UserID into tempusc
from uscu in tempusc.DefaultIfEmpty()
join usm in UserRepository.Entities
on courseTypeSet.ModifyUserID equals usm.UserID into tempusm
from usmu in tempusm.DefaultIfEmpty()
select new CourseTypeSetView
{
CourseTypeSelectCourseTypeID = courseTypeSet.CourseTypeSelectCourseTypeID == null ? Guid.Empty : courseTypeSet.CourseTypeSelectCourseTypeID,
CourseTypeID = courseType.Value,
CourseTypeName = courseType.Name,
ColourBlock = "",
CourseTypeColour = (courseTypeSet.CourseTypeColour == null || courseTypeSet.CourseTypeColour == "") ? "white" : courseTypeSet.CourseTypeColour,
IsRequired = courseTypeSet.IsRequired == null ? false : courseTypeSet.IsRequired,
IsOptionalCourse = courseTypeSet.IsOptionalCourse == null ? false : courseTypeSet.IsOptionalCourse,
IsFreeSelectionCourse = courseTypeSet.IsFreeSelectionCourse == null ? false : courseTypeSet.IsFreeSelectionCourse,
IsDisplay = courseType.RecordStatus > (int)SYS_STATUS.UNUSABLE ? true : false,
RecordStatus = courseTypeSet.RecordStatus,
CreateUserID = courseTypeSet.CreateUserID,
CreateUserName = uscu.Name,
CreateTime = courseTypeSet.CreateTime,
ModifyUserID = courseTypeSet.ModifyUserID,
ModifyUserName = usmu.Name,
ModifyTime = courseTypeSet.ModifyTime
};
return query;
}
///
/// 查询对应的课程类型设定信息View(设定表与对应的字典表信息内联)
///
///
///
public IQueryable GetCourseTypeSelectCourseType(Expression> exp)
{
var query = from courseTypeSet in CourseTypeSelectCourseTypeRepository.GetList(exp)
join courseType in DictionaryItemRepository.GetList(x => x.DictionaryCode == typeof(CF_CourseType).Name)
on courseTypeSet.CourseTypeID equals courseType.Value
join usc in UserRepository.Entities
on courseTypeSet.CreateUserID equals usc.UserID into tempusc
from uscu in tempusc.DefaultIfEmpty()
join usm in UserRepository.Entities
on courseTypeSet.ModifyUserID equals usm.UserID into tempusm
from usmu in tempusm.DefaultIfEmpty()
select new CourseTypeSetView
{
CourseTypeSelectCourseTypeID = courseTypeSet.CourseTypeSelectCourseTypeID,
CourseTypeID = courseType.Value.Value,
CourseTypeName = courseType.Name,
ColourBlock = "",
CourseTypeColour = (courseTypeSet.CourseTypeColour == null || courseTypeSet.CourseTypeColour == "") ? "white" : courseTypeSet.CourseTypeColour,
IsRequired = courseTypeSet.IsRequired,
IsOptionalCourse = courseTypeSet.IsOptionalCourse,
IsFreeSelectionCourse = courseTypeSet.IsFreeSelectionCourse,
IsDisplay = courseType.RecordStatus > (int)SYS_STATUS.UNUSABLE ? true : false,
RecordStatus = courseTypeSet.RecordStatus,
CreateUserID = courseTypeSet.CreateUserID,
CreateUserName = uscu.Name,
CreateTime = courseTypeSet.CreateTime,
ModifyUserID = courseTypeSet.ModifyUserID,
ModifyUserName = usmu.Name,
ModifyTime = courseTypeSet.ModifyTime
};
return query;
}
}
}