123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using EMIS.DataLogic.Repositories;
- using EMIS.Entities;
- using Bowin.Common.Linq.Entity;
- using EMIS.ViewModel;
- using EMIS.DataLogic.Common.AdministrativeOrgan;
- using System.Linq.Expressions;
- namespace EMIS.CommonLogic.AdministrativeOrgan
- {
- public class UniversityServices : BaseServices,IUniversityServices
- {
- public UniversityDAL UniversityDAL { get; set; }
- /// <summary>
- /// 查询学校信息View
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public IGridResultSet<UniversityView> GetUniversityViewGrid(ConfiguretView configuretView, int pageIndex, int pageSize)
- {
- //学校信息
- Expression<Func<CF_University, bool>> expUniversity = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- var query = UniversityDAL.GetUniversityViewQueryable(expUniversity);
- //查询条件
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return query
- .OrderBy(x => x.Code.Length).ThenBy(x => x.Code)
- .ToGridResultSet<UniversityView>(pageIndex, pageSize);
- }
- /// <summary>
- /// 查询学校信息List
- /// </summary>
- /// <param name="configuretView"></param>
- /// <returns></returns>
- public IList<UniversityView> GetUniversityViewList(ConfiguretView configuretView)
- {
- //学校信息
- Expression<Func<CF_University, bool>> expUniversity = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- var query = UniversityDAL.GetUniversityViewQueryable(expUniversity);
- //查询条件
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return query
- .OrderBy(x => x.Code.Length).ThenBy(x => x.Code)
- .ToList();
- }
- /// <summary>
- /// 查询全部学校信息CF_University
- /// </summary>
- /// <returns></returns>
- public List<CF_University> GetUniversityList()
- {
- //学校信息
- Expression<Func<CF_University, bool>> expUniversity = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- var query = UniversityDAL.UniversityRepository.GetList(expUniversity);
- return query
- .OrderBy(x => x.Code.Length).ThenBy(x => x.Code)
- .ToList();
- }
- /// <summary>
- /// 查询对应的学校信息UniversityView
- /// </summary>
- /// <param name="universityID"></param>
- /// <returns></returns>
- public UniversityView GetUniversityView(Guid? universityID)
- {
- try
- {
- var query = UniversityDAL.GetUniversityViewQueryable(x => x.UniversityID == universityID)
- .SingleOrDefault();
- return query;
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 编辑(新增、修改,业务主键:学校代码或学校名称)
- /// </summary>
- /// <param name="universityView"></param>
- public void UniversityEdit(UniversityView universityView)
- {
- try
- {
- //查询数据库进行验证
- var universityVerification = UniversityDAL.UniversityRepository
- .GetList(x => x.UniversityID != universityView.UniversityID
- && (x.Code == universityView.Code
- || x.Name == universityView.Name))
- .FirstOrDefault();
- if (universityVerification == null)
- {
- //数据有误验证
- if (universityView.UniversityID != Guid.Empty)
- {
- var university = UniversityDAL.UniversityRepository
- .GetList(x => x.UniversityID == universityView.UniversityID)
- .SingleOrDefault();
- var universityProfile = UniversityDAL.UniversityProfileRepository
- .GetList(x => x.UniversityID == universityView.UniversityID)
- .SingleOrDefault();
- if (university == null)
- {
- throw new Exception("数据有误,请核查");
- }
- else
- {
- //表示修改
- university.Code = universityView.Code;
- university.Name = universityView.Name;
- university.SimpleName = universityView.SimpleName;
- university.EnglishName = universityView.EnglishName;
- university.Remark = universityView.Remark;
- SetModifyStatus(university);
- //学校信息扩展表
- if (universityProfile == null)
- {
- //新增
- var newUniversityProfile = new CF_UniversityProfile();
- newUniversityProfile.UniversityID = universityView.UniversityID;
- newUniversityProfile.ProvinceID = universityView.ProvinceID;
- newUniversityProfile.CityID = universityView.CityID;
- newUniversityProfile.DistrictID = universityView.DistrictID;
- newUniversityProfile.PropertyID = universityView.PropertyID;
- newUniversityProfile.SchoolTypeID = universityView.SchoolTypeID;
- newUniversityProfile.ManagerID = universityView.ManagerID;
- newUniversityProfile.FounderTypeID = universityView.FounderTypeID;
- newUniversityProfile.SchoolLevelID = universityView.SchoolLevelID;
- newUniversityProfile.HeadMasterName = universityView.HeadMasterName;
- newUniversityProfile.PartyManageID = universityView.PartyManageID;
- newUniversityProfile.LegalPersonName = universityView.LegalPersonName;
- newUniversityProfile.BuildDate = universityView.BuildDate;
- newUniversityProfile.AnniversaryDate = universityView.AnniversaryDate;
- newUniversityProfile.SchoolBasis = universityView.SchoolBasis;
- newUniversityProfile.SchoolMotto = universityView.SchoolMotto;
- newUniversityProfile.SubjectCount = universityView.SubjectCount;
- newUniversityProfile.Is211University = universityView.Is211University;
- newUniversityProfile.IsKeyUniversity = universityView.IsKeyUniversity;
- newUniversityProfile.IsAdultCollege = universityView.IsAdultCollege;
- newUniversityProfile.IsPostCollege = universityView.IsPostCollege;
- newUniversityProfile.IsNetCollege = universityView.IsNetCollege;
- newUniversityProfile.Telephone = universityView.Telephone;
- newUniversityProfile.ZIPCode = universityView.ZIPCode;
- newUniversityProfile.Email = universityView.Email;
- newUniversityProfile.FAX = universityView.FAX;
- newUniversityProfile.PublicNum = universityView.PublicNum;
- newUniversityProfile.HomePage = universityView.HomePage;
- newUniversityProfile.Address = universityView.Address;
- newUniversityProfile.EnglishAddress = universityView.EnglishAddress;
- newUniversityProfile.HistoryEvolution = universityView.HistoryEvolution;
- SetNewStatus(newUniversityProfile);
- UnitOfWork.Add(newUniversityProfile);
-
- }
- else
- {
- //修改
- universityProfile.ProvinceID = universityView.ProvinceID;
- universityProfile.CityID = universityView.CityID;
- universityProfile.DistrictID = universityView.DistrictID;
- universityProfile.PropertyID = universityView.PropertyID;
- universityProfile.SchoolTypeID = universityView.SchoolTypeID;
- universityProfile.ManagerID = universityView.ManagerID;
- universityProfile.FounderTypeID = universityView.FounderTypeID;
- universityProfile.SchoolLevelID = universityView.SchoolLevelID;
- universityProfile.HeadMasterName = universityView.HeadMasterName;
- universityProfile.PartyManageID = universityView.PartyManageID;
- universityProfile.LegalPersonName = universityView.LegalPersonName;
- universityProfile.BuildDate = universityView.BuildDate;
- universityProfile.AnniversaryDate = universityView.AnniversaryDate;
- universityProfile.SchoolBasis = universityView.SchoolBasis;
- universityProfile.SchoolMotto = universityView.SchoolMotto;
- universityProfile.SubjectCount = universityView.SubjectCount;
- universityProfile.Is211University = universityView.Is211University;
- universityProfile.IsKeyUniversity = universityView.IsKeyUniversity;
- universityProfile.IsAdultCollege = universityView.IsAdultCollege;
- universityProfile.IsPostCollege = universityView.IsPostCollege;
- universityProfile.IsNetCollege = universityView.IsNetCollege;
- universityProfile.Telephone = universityView.Telephone;
- universityProfile.ZIPCode = universityView.ZIPCode;
- universityProfile.Email = universityView.Email;
- universityProfile.FAX = universityView.FAX;
- universityProfile.PublicNum = universityView.PublicNum;
- universityProfile.HomePage = universityView.HomePage;
- universityProfile.Address = universityView.Address;
- universityProfile.EnglishAddress = universityView.EnglishAddress;
- universityProfile.HistoryEvolution = universityView.HistoryEvolution;
- SetModifyStatus(universityProfile);
- }
- }
- }
- else
- {
- //表示新增(CF_University主表)
- CF_University university = new CF_University();
- university.UniversityID = Guid.NewGuid();
- university.Code = universityView.Code;
- university.Name = universityView.Name;
- university.SimpleName = universityView.SimpleName;
- university.EnglishName = universityView.EnglishName;
- university.Remark = universityView.Remark;
- SetNewStatus(university);
- UnitOfWork.Add(university);
- //表示新增(CF_UniversityProfile扩展表)
- CF_UniversityProfile universityProfile = new CF_UniversityProfile();
- universityProfile.UniversityID = university.UniversityID;
- universityProfile.ProvinceID = universityView.ProvinceID;
- universityProfile.CityID = universityView.CityID;
- universityProfile.DistrictID = universityView.DistrictID;
- universityProfile.PropertyID = universityView.PropertyID;
- universityProfile.SchoolTypeID = universityView.SchoolTypeID;
- universityProfile.ManagerID = universityView.ManagerID;
- universityProfile.FounderTypeID = universityView.FounderTypeID;
- universityProfile.SchoolLevelID = universityView.SchoolLevelID;
- universityProfile.HeadMasterName = universityView.HeadMasterName;
- universityProfile.PartyManageID = universityView.PartyManageID;
- universityProfile.LegalPersonName = universityView.LegalPersonName;
- universityProfile.BuildDate = universityView.BuildDate;
- universityProfile.AnniversaryDate = universityView.AnniversaryDate;
- universityProfile.SchoolBasis = universityView.SchoolBasis;
- universityProfile.SchoolMotto = universityView.SchoolMotto;
- universityProfile.SubjectCount = universityView.SubjectCount;
- universityProfile.Is211University = universityView.Is211University;
- universityProfile.IsKeyUniversity = universityView.IsKeyUniversity;
- universityProfile.IsAdultCollege = universityView.IsAdultCollege;
- universityProfile.IsPostCollege = universityView.IsPostCollege;
- universityProfile.IsNetCollege = universityView.IsNetCollege;
- universityProfile.Telephone = universityView.Telephone;
- universityProfile.ZIPCode = universityView.ZIPCode;
- universityProfile.Email = universityView.Email;
- universityProfile.FAX = universityView.FAX;
- universityProfile.PublicNum = universityView.PublicNum;
- universityProfile.HomePage = universityView.HomePage;
- universityProfile.Address = universityView.Address;
- universityProfile.EnglishAddress = universityView.EnglishAddress;
- universityProfile.HistoryEvolution = universityView.HistoryEvolution;
- SetNewStatus(universityProfile);
- UnitOfWork.Add(universityProfile);
- }
- }
- else
- {
- throw new Exception("已存在相同的学校代码或学校名称,请核查");
- }
- //事务提交
- UnitOfWork.Commit();
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="universityIDList"></param>
- /// <returns></returns>
- public bool UniversityDelete(List<Guid?> universityIDList)
- {
- try
- {
- UnitOfWork.Delete<CF_University>(x => universityIDList.Contains(x.UniversityID));
- UnitOfWork.Commit();
- return true;
- }
- catch (Exception)
- {
- throw;
- }
- }
- }
- }
|