using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EMIS.DataLogic.Repositories;
using EMIS.ViewModel;
using System.Linq.Expressions;
using EMIS.Entities;
namespace EMIS.DataLogic.Common.AdministrativeOrgan
{
public class CollegeDAL
{
public CollegeRepository CollegeRepository { get; set; }
public CollegeProfileRepository CollegeProfileRepository { get; set; }
public CampusRepository CampusRepository { get; set; }
public UserRepository UserRepository { get; set; }
public StaffRepository StaffRepository { get; set; }
///
/// 查询对应的院系所信息CollegeView
///
///
public IQueryable GetCollegeViewQueryable()
{
var query = from col in CollegeRepository.Entities
from cam in CampusRepository.Entities.Where(x => x.CampusID == col.CampusID).DefaultIfEmpty()
join e in UserRepository.Entities
on col.CF_CollegeProfile.PoliticalManager equals e.UserID
into gpm
from gPoliticalManager in gpm.DefaultIfEmpty()
join f in UserRepository.Entities
on col.CF_CollegeProfile.AdministrativeManager equals f.UserID
into gam
from gAdministrativeManager in gam.DefaultIfEmpty()
select new CollegeView
{
CollegeID = col.CollegeID,
No = col.No,
Name = col.Name,
SimpleName = col.SimpleName,
EnglishName = col.EnglishName,
CampusID = col.CampusID,
CampusNo = cam.No,
CampusName = cam.Name,
PoliticalManager = col.CF_CollegeProfile.PoliticalManager,
PoliticalManagerName = gPoliticalManager.Name,
AdministrativeManager = col.CF_CollegeProfile.AdministrativeManager,
AdministrativeManagerName = gAdministrativeManager.Name,
UnitCategoryID = col.CF_CollegeProfile.UnitCategoryID,
CollegeTypeID = col.CF_CollegeProfile.CollegeTypeID,
CollegeCategoryID = col.CF_CollegeProfile.CollegeCategoryID,
RunByCategoryID = col.CF_CollegeProfile.RunByCategoryID,
FoundDate = col.CF_CollegeProfile.FoundDate,
Officephone = col.CF_CollegeProfile.Officephone,
Remark = col.Remark,
RecordStatus = col.RecordStatus,
CreateUserID = col.CreateUserID,
CreateTime = col.CreateTime,
ModifyUserID = col.ModifyUserID,
ModifyTime = col.ModifyTime
};
return query;
}
///
/// 查询对应的院系所信息CollegeView
///
///
///
public IQueryable GetCollegeViewQueryable(Expression> expCollege)
{
var query = from col in CollegeRepository.GetList(expCollege)
from cam in CampusRepository.Entities.Where(x => x.CampusID == col.CampusID).DefaultIfEmpty()
join e in UserRepository.Entities
on col.CF_CollegeProfile.PoliticalManager equals e.UserID
into gpm
from gPoliticalManager in gpm.DefaultIfEmpty()
join f in UserRepository.Entities
on col.CF_CollegeProfile.AdministrativeManager equals f.UserID
into gam
from gAdministrativeManager in gam.DefaultIfEmpty()
select new CollegeView
{
CollegeID = col.CollegeID,
No = col.No,
Name = col.Name,
SimpleName = col.SimpleName,
EnglishName = col.EnglishName,
CampusID = col.CampusID,
CampusNo = cam.No,
CampusName = cam.Name,
PoliticalManager = col.CF_CollegeProfile.PoliticalManager,
PoliticalManagerName = gPoliticalManager.Name,
AdministrativeManager = col.CF_CollegeProfile.AdministrativeManager,
AdministrativeManagerName = gAdministrativeManager.Name,
UnitCategoryID = col.CF_CollegeProfile.UnitCategoryID,
CollegeTypeID = col.CF_CollegeProfile.CollegeTypeID,
CollegeCategoryID = col.CF_CollegeProfile.CollegeCategoryID,
RunByCategoryID = col.CF_CollegeProfile.RunByCategoryID,
FoundDate = col.CF_CollegeProfile.FoundDate,
Officephone = col.CF_CollegeProfile.Officephone,
Remark = col.Remark,
RecordStatus = col.RecordStatus,
CreateUserID = col.CreateUserID,
CreateTime = col.CreateTime,
ModifyUserID = col.ModifyUserID,
ModifyTime = col.ModifyTime
};
return query;
}
///
/// 查询对应的院系所信息CollegeView(只显示院、系、部类别的院系所)
///
///
///
public IQueryable GetOnlyCollegeViewQueryable(Expression> expCollege)
{
var query = from col in CollegeRepository.GetList(expCollege)
from cam in CampusRepository.Entities.Where(x => x.CampusID == col.CampusID).DefaultIfEmpty()
where col.CF_CollegeProfile.UnitCategoryID == (int)CF_UnitCategory.College
select new CollegeView
{
CollegeID = col.CollegeID,
No = col.No,
Name = col.Name,
SimpleName = col.SimpleName,
EnglishName = col.EnglishName,
CampusID = col.CampusID,
CampusNo = cam.No,
CampusName = cam.Name,
UnitCategoryID = col.CF_CollegeProfile.UnitCategoryID,
CollegeTypeID = col.CF_CollegeProfile.CollegeTypeID,
CollegeCategoryID = col.CF_CollegeProfile.CollegeCategoryID,
RunByCategoryID = col.CF_CollegeProfile.RunByCategoryID,
FoundDate = col.CF_CollegeProfile.FoundDate,
Officephone = col.CF_CollegeProfile.Officephone,
Remark = col.Remark,
RecordStatus = col.RecordStatus,
CreateUserID = col.CreateUserID,
CreateTime = col.CreateTime,
ModifyUserID = col.ModifyUserID,
ModifyTime = col.ModifyTime
};
return query;
}
}
}