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 GetLearningformRateViewList(ConfiguretView learningformRateConditionView, int pageIndex, int pageSize) { Expression> 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(pageIndex, pageSize); } public List GetLearningformRateViewList() { Expression> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); var query = LearningformRateDAL.GetLearningformRateViewQueryable(exp); query = query.OrderBy(x => x.LearningformID); return query.ToList(); } /// /// 获取考试时间信息 /// /// 考试时间ID /// public LearningformRateView GetLearningformRateView(Guid? learningformRateID) { var query = LearningformRateDAL.GetLearningformRateViewQueryable(x => x.LearningformRateID == learningformRateID); return query.FirstOrDefault(); } /// /// 保存 /// /// 实体 /// 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 learningformRateIDList) { if (learningformRateIDList.Count > 0) { UnitOfWork.Delete(x => learningformRateIDList.Contains(x.LearningformRateID)); } } } }