PracticeRateServices.cs 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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 PracticeRateServices : BaseServices, IPracticeRateServices
  14. {
  15. public PracticeRateDAL PracticeRateDAL { get; set; }
  16. public IGridResultSet<PracticeRateView> GetPracticeRateViewList(ConfiguretView practiceRateConditionView, int pageIndex, int pageSize)
  17. {
  18. Expression<Func<TP_PracticeRate, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  19. var query = PracticeRateDAL.GetPracticeRateViewQueryable(exp);
  20. if (!string.IsNullOrEmpty(practiceRateConditionView.ConditionValue) && !string.IsNullOrEmpty(practiceRateConditionView.Attribute))
  21. query = query.DynamicWhere(practiceRateConditionView.Attribute, practiceRateConditionView.Condition, practiceRateConditionView.ConditionValue);
  22. query = query.OrderBy(x => x.CourseTypeID);
  23. return query.ToGridResultSet<PracticeRateView>(pageIndex, pageSize);
  24. }
  25. public List<PracticeRateView> GetPracticeRateViewList()
  26. {
  27. Expression<Func<TP_PracticeRate, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  28. var query = PracticeRateDAL.GetPracticeRateViewQueryable(exp);
  29. query = query.OrderBy(x => x.CourseTypeID);
  30. return query.ToList();
  31. }
  32. /// <summary>
  33. /// 获取考试时间信息
  34. /// </summary>
  35. /// <param name="practiceRateID">考试时间ID</param>
  36. /// <returns></returns>
  37. public PracticeRateView GetPracticeRateView(Guid? practiceRateID)
  38. {
  39. var query = PracticeRateDAL.GetPracticeRateViewQueryable(x => x.PracticeRateID == practiceRateID);
  40. return query.FirstOrDefault();
  41. }
  42. /// <summary>
  43. /// 保存
  44. /// </summary>
  45. /// <param name="practiceRate">实体</param>
  46. /// <returns></returns>
  47. public void Save(PracticeRateView practiceRateView)
  48. {
  49. TP_PracticeRate practiceRate = new TP_PracticeRate();
  50. if (practiceRateView.PracticeRateID == null || practiceRateView.PracticeRateID == Guid.Empty)
  51. {
  52. practiceRate = PracticeRateDAL.PracticeRateRepository.GetSingle(x => x.CourseTypeID == practiceRateView.CourseTypeID);
  53. if (practiceRate != null)
  54. {
  55. throw new Exception("已有相同课程类型的实践系数设置,请勿重复设置。");
  56. }
  57. practiceRate = new TP_PracticeRate();
  58. practiceRate.PracticeRateID = Guid.NewGuid();
  59. SetNewStatus(practiceRate);
  60. UnitOfWork.Add(practiceRate);
  61. }
  62. else
  63. {
  64. practiceRate = PracticeRateDAL.PracticeRateRepository.GetSingle(x => x.PracticeRateID != practiceRateView.PracticeRateID
  65. && x.CourseTypeID == practiceRateView.CourseTypeID);
  66. if (practiceRate != null)
  67. {
  68. throw new Exception("已有相同课程类型的实践系数设置,请勿重复设置。");
  69. }
  70. practiceRate = PracticeRateDAL.PracticeRateRepository.GetSingle(x => x.PracticeRateID == practiceRateView.PracticeRateID);
  71. if (practiceRate == null)
  72. {
  73. throw new Exception("未能找到需要修改的数据,数据可能已被其他用户更改。");
  74. }
  75. SetModifyStatus(practiceRate);
  76. }
  77. practiceRate.CourseTypeID = practiceRateView.CourseTypeID;
  78. practiceRate.Rate = practiceRateView.Rate;
  79. UnitOfWork.Commit();
  80. }
  81. public void Delete(IList<Guid?> practiceRateIDList)
  82. {
  83. if (practiceRateIDList.Count > 0)
  84. {
  85. UnitOfWork.Delete<TP_PracticeRate>(x => practiceRateIDList.Contains(x.PracticeRateID));
  86. }
  87. }
  88. }
  89. }