123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- 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 StudentCountRateServices : BaseServices, IStudentCountRateServices
- {
- public StudentCountRateDAL StudentCountRateDAL { get; set; }
- public IGridResultSet<StudentCountRateView> GetStudentCountRateViewList(ConfiguretView studentCountRateConditionView, int pageIndex, int pageSize)
- {
- Expression<Func<TP_StudentCountRate, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE && x.Title != null);
- var query = StudentCountRateDAL.GetStudentCountRateViewQueryable(exp);
- if (!string.IsNullOrEmpty(studentCountRateConditionView.ConditionValue) && !string.IsNullOrEmpty(studentCountRateConditionView.Attribute))
- query = query.DynamicWhere(studentCountRateConditionView.Attribute, studentCountRateConditionView.Condition, studentCountRateConditionView.ConditionValue);
- query = query.OrderBy(x => x.TitleID);
- return query.ToGridResultSet<StudentCountRateView>(pageIndex, pageSize);
- }
- public List<StudentCountRateView> GetStudentCountRateViewList()
- {
- Expression<Func<TP_StudentCountRate, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- var query = StudentCountRateDAL.GetStudentCountRateViewQueryable(exp);
- query = query.OrderBy(x => x.TitleID);
- return query.ToList();
- }
- public StudentCountRateView GetCommonStudentCountRateView()
- {
- Expression<Func<TP_StudentCountRate, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE && x.Title == null);
- var query = StudentCountRateDAL.GetStudentCountRateViewQueryable(exp);
- return query.FirstOrDefault();
- }
- /// <summary>
- /// 获取考试时间信息
- /// </summary>
- /// <param name="studentCountRateID">考试时间ID</param>
- /// <returns></returns>
- public StudentCountRateView GetStudentCountRateView(Guid? studentCountRateID)
- {
- var query = StudentCountRateDAL.GetStudentCountRateViewQueryable(x => x.StudentCountRateID == studentCountRateID);
- return query.FirstOrDefault();
- }
- /// <summary>
- /// 保存
- /// </summary>
- /// <param name="studentCountRate">实体</param>
- /// <returns></returns>
- public void Save(StudentCountRateView studentCountRateView)
- {
- TP_StudentCountRate studentCountRate = new TP_StudentCountRate();
- if (studentCountRateView.StudentCountRateID == null || studentCountRateView.StudentCountRateID == Guid.Empty)
- {
- studentCountRate = StudentCountRateDAL.StudentCountRateRepository.GetSingle(x => x.Title == studentCountRateView.TitleID);
- if (studentCountRate != null)
- {
- throw new Exception("已有相同职称的人数系数设置,请勿重复设置。");
- }
- studentCountRate = new TP_StudentCountRate();
- studentCountRate.StudentCountRateID = Guid.NewGuid();
- SetNewStatus(studentCountRate);
- UnitOfWork.Add(studentCountRate);
- }
- else
- {
- studentCountRate = StudentCountRateDAL.StudentCountRateRepository.GetSingle(x => x.StudentCountRateID != studentCountRateView.StudentCountRateID
- && x.Title == studentCountRateView.TitleID);
- if (studentCountRate != null)
- {
- throw new Exception("已有相同职称的人数系数设置,请勿重复设置。");
- }
- studentCountRate = StudentCountRateDAL.StudentCountRateRepository.GetSingle(x => x.StudentCountRateID == studentCountRateView.StudentCountRateID);
- if (studentCountRate == null)
- {
- throw new Exception("未能找到需要修改的数据,数据可能已被其他用户更改。");
- }
- SetModifyStatus(studentCountRate);
- }
- studentCountRate.Title = studentCountRateView.TitleID;
- studentCountRate.BaseStudentCount = studentCountRateView.BaseStudentCount;
- studentCountRate.Limit = studentCountRateView.Limit;
- UnitOfWork.Commit();
- }
- public void Delete(IList<Guid?> studentCountRateIDList)
- {
- if (studentCountRateIDList.Count > 0)
- {
- UnitOfWork.Delete<TP_StudentCountRate>(x => studentCountRateIDList.Contains(x.StudentCountRateID));
- }
- }
- }
- }
|