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 PracticeRateServices : BaseServices, IPracticeRateServices { public PracticeRateDAL PracticeRateDAL { get; set; } public IGridResultSet GetPracticeRateViewList(ConfiguretView practiceRateConditionView, int pageIndex, int pageSize) { Expression> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); var query = PracticeRateDAL.GetPracticeRateViewQueryable(exp); if (!string.IsNullOrEmpty(practiceRateConditionView.ConditionValue) && !string.IsNullOrEmpty(practiceRateConditionView.Attribute)) query = query.DynamicWhere(practiceRateConditionView.Attribute, practiceRateConditionView.Condition, practiceRateConditionView.ConditionValue); query = query.OrderBy(x => x.CourseTypeID); return query.ToGridResultSet(pageIndex, pageSize); } public List GetPracticeRateViewList() { Expression> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); var query = PracticeRateDAL.GetPracticeRateViewQueryable(exp); query = query.OrderBy(x => x.CourseTypeID); return query.ToList(); } /// /// 获取考试时间信息 /// /// 考试时间ID /// public PracticeRateView GetPracticeRateView(Guid? practiceRateID) { var query = PracticeRateDAL.GetPracticeRateViewQueryable(x => x.PracticeRateID == practiceRateID); return query.FirstOrDefault(); } /// /// 保存 /// /// 实体 /// public void Save(PracticeRateView practiceRateView) { TP_PracticeRate practiceRate = new TP_PracticeRate(); if (practiceRateView.PracticeRateID == null || practiceRateView.PracticeRateID == Guid.Empty) { practiceRate = PracticeRateDAL.PracticeRateRepository.GetSingle(x => x.CourseTypeID == practiceRateView.CourseTypeID); if (practiceRate != null) { throw new Exception("已有相同课程类型的实践系数设置,请勿重复设置。"); } practiceRate = new TP_PracticeRate(); practiceRate.PracticeRateID = Guid.NewGuid(); SetNewStatus(practiceRate); UnitOfWork.Add(practiceRate); } else { practiceRate = PracticeRateDAL.PracticeRateRepository.GetSingle(x => x.PracticeRateID != practiceRateView.PracticeRateID && x.CourseTypeID == practiceRateView.CourseTypeID); if (practiceRate != null) { throw new Exception("已有相同课程类型的实践系数设置,请勿重复设置。"); } practiceRate = PracticeRateDAL.PracticeRateRepository.GetSingle(x => x.PracticeRateID == practiceRateView.PracticeRateID); if (practiceRate == null) { throw new Exception("未能找到需要修改的数据,数据可能已被其他用户更改。"); } SetModifyStatus(practiceRate); } practiceRate.CourseTypeID = practiceRateView.CourseTypeID; practiceRate.Rate = practiceRateView.Rate; UnitOfWork.Commit(); } public void Delete(IList practiceRateIDList) { if (practiceRateIDList.Count > 0) { UnitOfWork.Delete(x => practiceRateIDList.Contains(x.PracticeRateID)); } } } }