123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Linq.Expressions;
- using System.Text;
- using EMIS.DataLogic.ScoreManage;
- using EMIS.ViewModel.ScoreManage;
- using EMIS.ViewModel;
- using EMIS.Entities;
- using Bowin.Common.Linq;
- using Bowin.Common.Linq.Entity;
- namespace EMIS.CommonLogic.ScoreManage
- {
- public class ScoreParamterCollegeSettingServices : BaseServices, IScoreParamterCollegeSettingServices
- {
- public ScoreParameterCollegeSettingDAL ScoreParameterCollegeSettingDAL { get; set; }
- public IGridResultSet<ScoreParameterCollegeSettingView> GetScoreParameterCollegeSettingViewGrid(ConfiguretView configuretView,
- Guid? collegeID, int? yearsID, int? pageIndex, int? pageSize)
- {
- Expression<Func<ER_ScoreParameterCollegeSetting, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (collegeID.HasValue)
- exp = exp.And(x => x.CollegeID == collegeID);
- if (yearsID.HasValue)
- exp = exp.And(x => x.Years == yearsID);
- var query = ScoreParameterCollegeSettingDAL.GetScoreParameterCollegeSettingViewQueryable(exp);
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- return this.GetQueryByDataRangeByCollege(query)
- .OrderByDescending(x => x.Years)
- .ThenBy(x => x.CollegeNo.Length)
- .ThenBy(x => x.CollegeNo)
- .ToGridResultSet(pageIndex, pageSize);
- }
- public ScoreParameterCollegeSettingView GetScoreParameterCollegeSettingView(Guid scoreParameterCollegeSettingID)
- {
- Expression<Func<ER_ScoreParameterCollegeSetting, bool>> exp = (x => x.ScoreParameterCollegeSettingID == scoreParameterCollegeSettingID);
- return this.ScoreParameterCollegeSettingDAL.GetScoreParameterCollegeSettingViewQueryable(exp).FirstOrDefault();
- }
- public List<ScoreParameterSettingView> GetScoreParameterSettingViewForDetail(Guid? scoreParameterCollegeSettingID)
- {
- Expression<Func<ER_ScoreParameterCollegeSettingDetail, bool>> exp = (x => x.ScoreParameterCollegeSettingID == scoreParameterCollegeSettingID);
- return this.ScoreParameterCollegeSettingDAL.GetScoreParameterSettingViewQueryable(exp).ToList();
- }
- public void Delete(IList<Guid?> scoreParameterCollegeSettingIDList)
- {
- this.UnitOfWork.Remove<ER_ScoreParameterCollegeSettingDetail>(x => scoreParameterCollegeSettingIDList.Contains(x.ScoreParameterCollegeSettingID));
- this.UnitOfWork.Remove<ER_ScoreParameterCollegeSetting>(x => scoreParameterCollegeSettingIDList.Contains(x.ScoreParameterCollegeSettingID));
- this.UnitOfWork.Commit();
- }
- public void Save(ScoreParameterCollegeSettingView scoreParameterCollegeSettingView, IList<ScoreParameterSettingView> detailParameterViewList)
- {
- var entity = ScoreParameterCollegeSettingDAL.ScoreParameterCollegeSettingRepository.GetSingle(x => x.ScoreParameterCollegeSettingID == scoreParameterCollegeSettingView.ScoreParameterCollegeSettingID,
- (x => x.ER_ScoreParameterCollegeSettingDetail));
- if (entity == null)
- {
- entity = new ER_ScoreParameterCollegeSetting();
- entity.ScoreParameterCollegeSettingID = Guid.NewGuid();
- this.SetNewStatus(entity);
- UnitOfWork.Add(entity);
- }
- else
- {
- this.SetModifyStatus(entity);
- }
- var dupEntity = ScoreParameterCollegeSettingDAL.ScoreParameterCollegeSettingRepository.GetSingle(x => x.Years == scoreParameterCollegeSettingView.Years
- && x.CollegeID == scoreParameterCollegeSettingView.CollegeID
- && x.ScoreParameterCollegeSettingID != scoreParameterCollegeSettingView.ScoreParameterCollegeSettingID);
- if (dupEntity != null)
- {
- throw(new Exception("该年度已经有其他设置,无法保存。"));
- }
- entity.Years = scoreParameterCollegeSettingView.Years;
- entity.CollegeID = scoreParameterCollegeSettingView.CollegeID;
- entity.ScoreTypeID = scoreParameterCollegeSettingView.ScoreTypeID;
- this.UnitOfWork.Remove<ER_ScoreParameterCollegeSettingDetail>(x => x.ScoreParameterCollegeSettingID == entity.ScoreParameterCollegeSettingID);
- entity.ER_ScoreParameterCollegeSettingDetail = new HashSet<ER_ScoreParameterCollegeSettingDetail>();
- detailParameterViewList.ToList().ForEach(x => {
- var detail = new ER_ScoreParameterCollegeSettingDetail();
- detail.ScoreParameterCollegeSettingDetailID = Guid.NewGuid();
- detail.ScoreParameterCollegeSettingID = entity.ScoreParameterCollegeSettingID;
- detail.ExamsCategoryID = x.ExamsTypeID;
- detail.CourseTypeID = x.CourseTypeID;
- detail.ScoreFormulaID = x.ScoreFormulaID;
- detail.IsTotalFormula = x.IsTotalFormula;
- detail.CreditFormulaID = x.CreditFormulaID;
- detail.IsCreditFormula = x.IsCreditFormula;
- detail.GradePointFormulaID = x.GradePointFormulaID;
- detail.IsGradePointFormula = x.IsGradePointFormula;
- UnitOfWork.Add(detail);
- });
- this.UnitOfWork.Commit();
- }
- public ScoreParameterCollegeSettingView GetScoreParameterCollegeSettingView(Guid? collegeID, int? year)
- {
- var collegeSetting = ScoreParameterCollegeSettingDAL.GetScoreParameterCollegeSettingViewQueryable(x => x.CollegeID == collegeID
- && x.Years == year).FirstOrDefault();
- if (collegeSetting == null)
- {
- collegeSetting = ScoreParameterCollegeSettingDAL.GetScoreParameterCollegeSettingViewQueryable(x => x.CollegeID == null
- && x.Years == year).FirstOrDefault();
- }
- return collegeSetting;
- }
- }
- }
|