LearningformRateServices.cs 4.7 KB

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