123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- 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<PracticeRateView> GetPracticeRateViewList(ConfiguretView practiceRateConditionView, int pageIndex, int pageSize)
- {
- Expression<Func<TP_PracticeRate, bool>> 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<PracticeRateView>(pageIndex, pageSize);
- }
- public List<PracticeRateView> GetPracticeRateViewList()
- {
- Expression<Func<TP_PracticeRate, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- var query = PracticeRateDAL.GetPracticeRateViewQueryable(exp);
- query = query.OrderBy(x => x.CourseTypeID);
- return query.ToList();
- }
- /// <summary>
- /// 获取考试时间信息
- /// </summary>
- /// <param name="practiceRateID">考试时间ID</param>
- /// <returns></returns>
- public PracticeRateView GetPracticeRateView(Guid? practiceRateID)
- {
- var query = PracticeRateDAL.GetPracticeRateViewQueryable(x => x.PracticeRateID == practiceRateID);
- return query.FirstOrDefault();
- }
- /// <summary>
- /// 保存
- /// </summary>
- /// <param name="practiceRate">实体</param>
- /// <returns></returns>
- 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<Guid?> practiceRateIDList)
- {
- if (practiceRateIDList.Count > 0)
- {
- UnitOfWork.Delete<TP_PracticeRate>(x => practiceRateIDList.Contains(x.PracticeRateID));
- }
- }
- }
- }
|