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.EnrollManage.SpecialtyManage;
using EMIS.DataLogic.Repositories;
namespace EMIS.DataLogic.EnrollManage.SpecialtyManage
{
public class SpecialtyApplyDAL
{
public SpecialtyApplyRepository specialtyApplyRepository { get; set; }
public SpecialtyRepository specialtyRepository { get; set; }
public CollegeRepository collegeRepository { get; set; }
public CampusRepository campusRepository { get; set; }
public DictionaryItemRepository dictionaryItemRepository { get; set; }
public RecruitSpecialtyRepository recruitSpecialtyRepository { get; set; }
public UserRepository userRepository { get; set; }
///
/// 查询专业申请信息SpecialtyApplyView
///
/// 条件查询
///
public IQueryable GetSpecialtyApplyViewQueryable(Expression> exp)
{
var query = from spay in specialtyApplyRepository.GetList(exp)
join sp in specialtyRepository.Entities
on spay.SpecialtyID equals sp.SpecialtyID
join col in collegeRepository.Entities
on spay.CollegeID equals col.CollegeID
join cam in campusRepository.Entities
on col.CampusID equals cam.CampusID
join stan in dictionaryItemRepository.GetList(x => x.DictionaryCode == DictionaryItem.CF_Standard.ToString())
on sp.StandardID equals stan.Value into tempstan
from dtstan in tempstan.DefaultIfEmpty()
join crus in userRepository.Entities
on spay.CreateUserID equals crus.UserID into tempcrus
from spaycrus in tempcrus.DefaultIfEmpty()
select new SpecialtyApplyView
{
SpecialtyApplyID = spay.SpecialtyApplyID,
SpecialtyID = spay.SpecialtyID,
StandardID = sp.StandardID,
StandardCode = dtstan.Code,
StandardName = dtstan.Name,
CollegeID = spay.CollegeID,
CollegeCode = col.No,
CollegeName = col.Name,
CampusID = col.CampusID,
CampusCode = cam.No,
CampusName = cam.Name,
GradeID = spay.GradeID,
SemesterID = spay.SemesterID,
EducationID = sp.EducationID,
LearningformID = sp.LearningformID,
LearnSystem = sp.LearnSystem,
ScienceclassID = sp.ScienceclassID,
StandardTitle = sp.StandardTitle,
StandardLevel = sp.StandardLevel,
PropertyID = sp.PropertyID,
ApprovalStatus = spay.ApprovalStatus,
Remark = spay.Remark,
RecordStatus = spay.RecordStatus,
CreateUserID = spay.CreateUserID,
CreateUserCode = spaycrus.LoginID,
CreateUserName = spaycrus.Name,
CreateTime = spay.CreateTime,
ModifyUserID = spay.ModifyUserID,
ModifyTime = spay.ModifyTime
};
return query;
}
///
/// 查询未进行申请的专业信息SpecialtyView
///
///
///
///
///
public IQueryable GetSpecialtyViewNoApplyQueryable(Expression> expSpecialty,
Expression> expSpecialtyApply, Expression> expRecruitSpecialty)
{
var query = from sp in specialtyRepository.GetList(expSpecialty)
join stan in dictionaryItemRepository.GetList(x => x.DictionaryCode == DictionaryItem.CF_Standard.ToString())
on sp.StandardID equals stan.Value into tempstan
from dtstan in tempstan.DefaultIfEmpty()
join spay in specialtyApplyRepository.GetList(expSpecialtyApply)
on sp.SpecialtyID equals spay.SpecialtyID into tempspay
from spapply in tempspay.DefaultIfEmpty()
join rs in recruitSpecialtyRepository.GetList(expRecruitSpecialty)
on sp.SpecialtyID equals rs.SpecialtyID into temprs
from rsp in temprs.DefaultIfEmpty()
where spapply.SpecialtyApplyID == null && rsp.RecruitSpecialtyID == null
select new SpecialtyView
{
SpecialtyID = sp.SpecialtyID,
StandardID = sp.StandardID,
StandardCode = dtstan.Code,
StandardName = dtstan.Name,
EducationID = sp.EducationID,
LearningformID = sp.LearningformID,
LearnSystem = sp.LearnSystem,
ScienceclassID = sp.ScienceclassID,
PropertyID = sp.PropertyID,
StandardTitle = sp.StandardTitle,
StandardLevel = sp.StandardLevel,
RecordStatus = sp.RecordStatus,
Remark = sp.Remark,
CreateUserID = sp.CreateUserID,
CreateTime = sp.CreateTime,
ModifyUserID = sp.ModifyUserID,
ModifyTime = sp.ModifyTime,
};
return query;
}
}
}