StudentCountRateServices.cs 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using EMIS.DataLogic.PaymentManage;
  6. using Bowin.Common.Linq.Entity;
  7. using EMIS.ViewModel.PaymentManage;
  8. using EMIS.ViewModel;
  9. using System.Linq.Expressions;
  10. using EMIS.Entities;
  11. namespace EMIS.CommonLogic.PaymentManage
  12. {
  13. public class StudentCountRateServices : BaseServices, IStudentCountRateServices
  14. {
  15. public StudentCountRateDAL StudentCountRateDAL { get; set; }
  16. public IGridResultSet<StudentCountRateView> GetStudentCountRateViewList(ConfiguretView studentCountRateConditionView, int pageIndex, int pageSize)
  17. {
  18. Expression<Func<TP_StudentCountRate, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE && x.Title != null);
  19. var query = StudentCountRateDAL.GetStudentCountRateViewQueryable(exp);
  20. if (!string.IsNullOrEmpty(studentCountRateConditionView.ConditionValue) && !string.IsNullOrEmpty(studentCountRateConditionView.Attribute))
  21. query = query.DynamicWhere(studentCountRateConditionView.Attribute, studentCountRateConditionView.Condition, studentCountRateConditionView.ConditionValue);
  22. query = query.OrderBy(x => x.TitleID);
  23. return query.ToGridResultSet<StudentCountRateView>(pageIndex, pageSize);
  24. }
  25. public List<StudentCountRateView> GetStudentCountRateViewList()
  26. {
  27. Expression<Func<TP_StudentCountRate, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  28. var query = StudentCountRateDAL.GetStudentCountRateViewQueryable(exp);
  29. query = query.OrderBy(x => x.TitleID);
  30. return query.ToList();
  31. }
  32. public StudentCountRateView GetCommonStudentCountRateView()
  33. {
  34. Expression<Func<TP_StudentCountRate, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE && x.Title == null);
  35. var query = StudentCountRateDAL.GetStudentCountRateViewQueryable(exp);
  36. return query.FirstOrDefault();
  37. }
  38. /// <summary>
  39. /// 获取考试时间信息
  40. /// </summary>
  41. /// <param name="studentCountRateID">考试时间ID</param>
  42. /// <returns></returns>
  43. public StudentCountRateView GetStudentCountRateView(Guid? studentCountRateID)
  44. {
  45. var query = StudentCountRateDAL.GetStudentCountRateViewQueryable(x => x.StudentCountRateID == studentCountRateID);
  46. return query.FirstOrDefault();
  47. }
  48. /// <summary>
  49. /// 保存
  50. /// </summary>
  51. /// <param name="studentCountRate">实体</param>
  52. /// <returns></returns>
  53. public void Save(StudentCountRateView studentCountRateView)
  54. {
  55. TP_StudentCountRate studentCountRate = new TP_StudentCountRate();
  56. if (studentCountRateView.StudentCountRateID == null || studentCountRateView.StudentCountRateID == Guid.Empty)
  57. {
  58. studentCountRate = StudentCountRateDAL.StudentCountRateRepository.GetSingle(x => x.Title == studentCountRateView.TitleID);
  59. if (studentCountRate != null)
  60. {
  61. throw new Exception("已有相同职称的人数系数设置,请勿重复设置。");
  62. }
  63. studentCountRate = new TP_StudentCountRate();
  64. studentCountRate.StudentCountRateID = Guid.NewGuid();
  65. SetNewStatus(studentCountRate);
  66. UnitOfWork.Add(studentCountRate);
  67. }
  68. else
  69. {
  70. studentCountRate = StudentCountRateDAL.StudentCountRateRepository.GetSingle(x => x.StudentCountRateID != studentCountRateView.StudentCountRateID
  71. && x.Title == studentCountRateView.TitleID);
  72. if (studentCountRate != null)
  73. {
  74. throw new Exception("已有相同职称的人数系数设置,请勿重复设置。");
  75. }
  76. studentCountRate = StudentCountRateDAL.StudentCountRateRepository.GetSingle(x => x.StudentCountRateID == studentCountRateView.StudentCountRateID);
  77. if (studentCountRate == null)
  78. {
  79. throw new Exception("未能找到需要修改的数据,数据可能已被其他用户更改。");
  80. }
  81. SetModifyStatus(studentCountRate);
  82. }
  83. studentCountRate.Title = studentCountRateView.TitleID;
  84. studentCountRate.BaseStudentCount = studentCountRateView.BaseStudentCount;
  85. studentCountRate.Limit = studentCountRateView.Limit;
  86. UnitOfWork.Commit();
  87. }
  88. public void Delete(IList<Guid?> studentCountRateIDList)
  89. {
  90. if (studentCountRateIDList.Count > 0)
  91. {
  92. UnitOfWork.Delete<TP_StudentCountRate>(x => studentCountRateIDList.Contains(x.StudentCountRateID));
  93. }
  94. }
  95. }
  96. }