123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- 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 PaymentStandardServices : BaseServices, IPaymentStandardServices
- {
- public PaymentStandardDAL PaymentStandardDAL { get; set; }
- public IGridResultSet<PaymentStandardView> GetPaymentStandardViewList(ConfiguretView paymentStandardConditionView, int pageIndex, int pageSize)
- {
- Expression<Func<TP_PaymentStandard, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- var query = PaymentStandardDAL.GetPaymentStandardViewQueryable(exp);
- if (!string.IsNullOrEmpty(paymentStandardConditionView.ConditionValue) && !string.IsNullOrEmpty(paymentStandardConditionView.Attribute))
- query = query.DynamicWhere(paymentStandardConditionView.Attribute, paymentStandardConditionView.Condition, paymentStandardConditionView.ConditionValue);
- query = query.OrderBy(x => x.TitleID).ThenBy(x => x.TeacherType);
- return query.ToGridResultSet<PaymentStandardView>(pageIndex, pageSize);
- }
- public List<PaymentStandardView> GetPaymentStandardViewList()
- {
- Expression<Func<TP_PaymentStandard, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- var query = PaymentStandardDAL.GetPaymentStandardViewQueryable(exp);
- query = query.OrderBy(x => x.TitleID).ThenBy(x => x.TeacherType);
- return query.ToList();
- }
- /// <summary>
- /// 获取考试时间信息
- /// </summary>
- /// <param name="paymentStandardID">考试时间ID</param>
- /// <returns></returns>
- public PaymentStandardView GetPaymentStandardView(Guid? paymentStandardID)
- {
- var query = PaymentStandardDAL.GetPaymentStandardViewQueryable(x => x.PaymentStandardID == paymentStandardID);
- return query.FirstOrDefault();
- }
- /// <summary>
- /// 保存
- /// </summary>
- /// <param name="paymentStandard">实体</param>
- /// <returns></returns>
- public void Save(PaymentStandardView paymentStandardView)
- {
- TP_PaymentStandard paymentStandard = new TP_PaymentStandard();
- if (paymentStandardView.PaymentStandardID == null || paymentStandardView.PaymentStandardID == Guid.Empty)
- {
- paymentStandard = PaymentStandardDAL.PaymentStandardRepository.GetSingle(x => x.Title == paymentStandardView.TitleID
- && x.TeacherType == paymentStandardView.TeacherType);
- if (paymentStandard != null)
- {
- throw new Exception("已有相同的标准课酬设置,请勿重复设置。");
- }
- paymentStandard = new TP_PaymentStandard();
- paymentStandard.PaymentStandardID = Guid.NewGuid();
- SetNewStatus(paymentStandard);
- UnitOfWork.Add(paymentStandard);
- }
- else
- {
- paymentStandard = PaymentStandardDAL.PaymentStandardRepository.GetSingle(x => x.PaymentStandardID != paymentStandardView.PaymentStandardID
- && x.Title == paymentStandardView.TitleID
- && x.TeacherType == paymentStandardView.TeacherType);
- if (paymentStandard != null)
- {
- throw new Exception("已有相同的标准课酬设置,请勿重复设置。");
- }
- paymentStandard = PaymentStandardDAL.PaymentStandardRepository.GetSingle(x => x.PaymentStandardID == paymentStandardView.PaymentStandardID);
- if (paymentStandard == null)
- {
- throw new Exception("未能找到需要修改的数据,数据可能已被其他用户更改。");
- }
- SetModifyStatus(paymentStandard);
- }
- paymentStandard.Title = paymentStandardView.TitleID;
- paymentStandard.TeacherType = paymentStandardView.TeacherType;
- paymentStandard.Amount = paymentStandardView.Amount;
- UnitOfWork.Commit();
- }
- public void Delete(IList<Guid?> paymentStandardIDList)
- {
- if (paymentStandardIDList.Count > 0)
- {
- UnitOfWork.Delete<TP_PaymentStandard>(x => paymentStandardIDList.Contains(x.PaymentStandardID));
- }
- }
- }
- }
|