123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using EMIS.DataLogic.Repositories;
- using EMIS.Entities;
- using EMIS.ViewModel;
- using Bowin.Common.Linq.Entity;
- using EMIS.DataLogic.Common.AdministrativeOrgan;
- using EMIS.Utility;
- using System.Linq.Expressions;
- namespace EMIS.CommonLogic.AdministrativeOrgan
- {
- public class CampusServices : BaseServices, ICampusServices
- {
- public CampusDAL CampusDAL { get; set; }
- /// <summary>
- /// 查询校区信息View
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public IGridResultSet<CampusView> GetCampusViewGrid(ConfiguretView configuretView, int pageIndex, int pageSize)
- {
- //校区信息
- Expression<Func<CF_Campus, bool>> expCampus = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- var query = CampusDAL.GetCampusViewQueryable(expCampus);
- //查询条件
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return this.GetQueryByDataRangeByCampus(query)
- .OrderBy(x => x.No.Length).ThenBy(x => x.No)
- .ToGridResultSet<CampusView>(pageIndex, pageSize);
- }
- /// <summary>
- /// 查询校区信息List
- /// </summary>
- /// <param name="configuretView"></param>
- /// <returns></returns>
- public IList<CampusView> GetCampusViewList(ConfiguretView configuretView)
- {
- //校区信息
- Expression<Func<CF_Campus, bool>> expCampus = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- var query = CampusDAL.GetCampusViewQueryable(expCampus);
- //查询条件
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return this.GetQueryByDataRangeByCampus(query)
- .OrderBy(x => x.No.Length).ThenBy(x => x.No)
- .ToList();
- }
- /// <summary>
- /// 查询全部校区信息CF_Campus
- /// </summary>
- /// <returns></returns>
- public List<CF_Campus> GetCampusList()
- {
- //校区信息
- Expression<Func<CF_Campus, bool>> expCampus = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- var query = CampusDAL.CampusRepository.GetList(expCampus);
- return this.GetQueryByDataRangeByCampus(query)
- .OrderBy(x => x.No.Length).ThenBy(x => x.No)
- .ToList();
- }
- /// <summary>
- /// 查询全部校区信息CF_Campus(不考虑状态列)
- /// </summary>
- /// <returns></returns>
- public List<CF_Campus> GetCampusListWithoutDataRange()
- {
- //校区信息
- Expression<Func<CF_Campus, bool>> expCampus = (x => true);
- var query = CampusDAL.CampusRepository.GetList(expCampus);
- return query.OrderBy(x => x.No.Length).ThenBy(x => x.No)
- .ToList();
- }
- /// <summary>
- /// 查询对应的校区信息CampusView
- /// </summary>
- /// <param name="campusID"></param>
- /// <returns></returns>
- public CampusView GetCampusView(Guid? campusID)
- {
- try
- {
- var query = CampusDAL.GetCampusViewQueryable(x => x.CampusID == campusID)
- .SingleOrDefault();
- return query;
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 编辑(新增、修改,业务主键:校区代码或校区名称)
- /// </summary>
- /// <param name="campusView"></param>
- public void CampusEdit(CampusView campusView)
- {
- try
- {
- //查询数据库进行验证
- var campusVerification = CampusDAL.CampusRepository
- .GetList(x => x.CampusID != campusView.CampusID
- && (x.No == campusView.No
- || x.Name == campusView.Name))
- .FirstOrDefault();
- if (campusVerification == null)
- {
- //数据有误验证
- if (campusView.CampusID != Guid.Empty)
- {
- var campus = CampusDAL.CampusRepository
- .GetList(x => x.CampusID == campusView.CampusID)
- .SingleOrDefault();
- var campusProfile = CampusDAL.CampusProfileRepository
- .GetList(x => x.CampusID == campusView.CampusID)
- .SingleOrDefault();
- if (campus == null)
- {
- throw new Exception("数据有误,请核查");
- }
- else
- {
- //表示修改
- campus.UniversityID = campusView.UniversityID;
- campus.No = campusView.No;
- campus.Name = campusView.Name;
- campus.SimpleName = campusView.SimpleName;
- campus.EnglishName = campusView.EnglishName;
- campus.Remark = campusView.Remark;
- SetModifyStatus(campusView);
- //校区信息扩展表
- if (campusProfile == null)
- {
- //新增
- var newCampusProfile = new CF_CampusProfile();
- newCampusProfile.CampusID = campusView.CampusID;
- newCampusProfile.Generalsuper = campusView.Generalsuper;
- newCampusProfile.Recruitstudents = campusView.Recruitstudents;
- newCampusProfile.Placesuper = campusView.Placesuper;
- newCampusProfile.Teachingsuper = campusView.Teachingsuper;
- newCampusProfile.Studentcharge = campusView.Studentcharge;
- newCampusProfile.ZIPCode = campusView.ZIPCode;
- newCampusProfile.Officephone = campusView.Officephone;
- newCampusProfile.FAX = campusView.FAX;
- newCampusProfile.Email = campusView.Email;
- newCampusProfile.Evolution = campusView.Evolution;
- SetNewStatus(newCampusProfile);
- UnitOfWork.Add(newCampusProfile);
- }
- else
- {
- //修改
- campusProfile.Generalsuper = campusView.Generalsuper;
- campusProfile.Recruitstudents = campusView.Recruitstudents;
- campusProfile.Placesuper = campusView.Placesuper;
- campusProfile.Teachingsuper = campusView.Teachingsuper;
- campusProfile.Studentcharge = campusView.Studentcharge;
- campusProfile.ZIPCode = campusView.ZIPCode;
- campusProfile.Officephone = campusView.Officephone;
- campusProfile.FAX = campusView.FAX;
- campusProfile.Email = campusView.Email;
- campusProfile.Evolution = campusView.Evolution;
- SetModifyStatus(campusProfile);
- }
- }
- }
- else
- {
- //表示新增(CF_Campus主表)
- CF_Campus campus = new CF_Campus();
- campus.CampusID = Guid.NewGuid();
- campus.UniversityID = campusView.UniversityID;
- campus.No = campusView.No;
- campus.Name = campusView.Name;
- campus.SimpleName = campusView.SimpleName;
- campus.EnglishName = campusView.EnglishName;
- campus.Remark = campusView.Remark;
- SetNewStatus(campus);
- UnitOfWork.Add(campus);
- //表示新增(CF_CampusProfile扩展表)
- CF_CampusProfile campusProfile = new CF_CampusProfile();
- campusProfile.CampusID = campus.CampusID;
- campusProfile.Generalsuper = campusView.Generalsuper;
- campusProfile.Recruitstudents = campusView.Recruitstudents;
- campusProfile.Placesuper = campusView.Placesuper;
- campusProfile.Teachingsuper = campusView.Teachingsuper;
- campusProfile.Studentcharge = campusView.Studentcharge;
- campusProfile.ZIPCode = campusView.ZIPCode;
- campusProfile.Officephone = campusView.Officephone;
- campusProfile.FAX = campusView.FAX;
- campusProfile.Email = campusView.Email;
- campusProfile.Evolution = campusView.Evolution;
- SetNewStatus(campusProfile);
- UnitOfWork.Add(campusProfile);
- }
- }
- else
- {
- throw new Exception("已存在相同的" + RSL.Get("CampusCode") + "或" + RSL.Get("CampusName") + ",请核查");
- }
- //事务提交
- UnitOfWork.Commit();
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="campusIDList"></param>
- /// <returns></returns>
- public bool CampusDelete(List<Guid?> campusIDList)
- {
- try
- {
- UnitOfWork.Delete<CF_Campus>(x => campusIDList.Contains(x.CampusID));
- UnitOfWork.Commit();
- return true;
- }
- catch (Exception)
- {
- throw;
- }
- }
- }
- }
|