123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using EMIS.DataLogic.PaymentManage;
- using Bowin.Common.Linq.Entity;
- using EMIS.ViewModel.PaymentManage;
- using EMIS.ViewModel;
- using System.Linq.Expressions;
- using EMIS.Entities;
- namespace EMIS.CommonLogic.PaymentManage
- {
- public class LearningformRateServices : BaseServices, ILearningformRateServices
- {
- public LearningformRateDAL LearningformRateDAL { get; set; }
- public IGridResultSet<LearningformRateView> GetLearningformRateViewList(ConfiguretView learningformRateConditionView, int pageIndex, int pageSize)
- {
- Expression<Func<TP_LearningformRate, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- var query = LearningformRateDAL.GetLearningformRateViewQueryable(exp);
- if (!string.IsNullOrEmpty(learningformRateConditionView.ConditionValue) && !string.IsNullOrEmpty(learningformRateConditionView.Attribute))
- query = query.DynamicWhere(learningformRateConditionView.Attribute, learningformRateConditionView.Condition, learningformRateConditionView.ConditionValue);
- query = query.OrderBy(x => x.LearningformID);
- return query.ToGridResultSet<LearningformRateView>(pageIndex, pageSize);
- }
- public List<LearningformRateView> GetLearningformRateViewList()
- {
- Expression<Func<TP_LearningformRate, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- var query = LearningformRateDAL.GetLearningformRateViewQueryable(exp);
- query = query.OrderBy(x => x.LearningformID);
- return query.ToList();
- }
- /// <summary>
- /// 获取考试时间信息
- /// </summary>
- /// <param name="learningformRateID">考试时间ID</param>
- /// <returns></returns>
- public LearningformRateView GetLearningformRateView(Guid? learningformRateID)
- {
- var query = LearningformRateDAL.GetLearningformRateViewQueryable(x => x.LearningformRateID == learningformRateID);
- return query.FirstOrDefault();
- }
- /// <summary>
- /// 保存
- /// </summary>
- /// <param name="learningformRate">实体</param>
- /// <returns></returns>
- public void Save(LearningformRateView learningformRateView)
- {
- TP_LearningformRate learningformRate = new TP_LearningformRate();
- if (learningformRateView.LearningformRateID == null || learningformRateView.LearningformRateID == Guid.Empty)
- {
- learningformRate = LearningformRateDAL.LearningformRateRepository.GetSingle(x => x.LearningformID == learningformRateView.LearningformID
- && x.EducationID == learningformRateView.EducationID);
- if (learningformRate != null)
- {
- throw new Exception("已有相同的学习形式系数设置,请勿重复设置。");
- }
- learningformRate = new TP_LearningformRate();
- learningformRate.LearningformRateID = Guid.NewGuid();
- SetNewStatus(learningformRate);
- UnitOfWork.Add(learningformRate);
- }
- else
- {
- learningformRate = LearningformRateDAL.LearningformRateRepository.GetSingle(x => x.LearningformRateID != learningformRateView.LearningformRateID
- && x.LearningformID == learningformRateView.LearningformID && x.EducationID == learningformRateView.EducationID);
- if (learningformRate != null)
- {
- throw new Exception("已有相同的学习形式系数设置,请勿重复设置。");
- }
- learningformRate = LearningformRateDAL.LearningformRateRepository.GetSingle(x => x.LearningformRateID == learningformRateView.LearningformRateID);
- if (learningformRate == null)
- {
- throw new Exception("未能找到需要修改的数据,数据可能已被其他用户更改。");
- }
- SetModifyStatus(learningformRate);
- }
- learningformRate.LearningformID = learningformRateView.LearningformID;
- learningformRate.EducationID = learningformRateView.EducationID;
- learningformRate.Rate = learningformRateView.Rate;
- UnitOfWork.Commit();
- }
- public void Delete(IList<Guid?> learningformRateIDList)
- {
- if (learningformRateIDList.Count > 0)
- {
- UnitOfWork.Delete<TP_LearningformRate>(x => learningformRateIDList.Contains(x.LearningformRateID));
- }
- }
- }
- }
|