ExaminationTypeServices.cs 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Linq.Expressions;
  6. using EMIS.DataLogic.ExaminationApply;
  7. using EMIS.ViewModel.ExaminationApply;
  8. using EMIS.ViewModel;
  9. using EMIS.Entities;
  10. using Bowin.Common.Linq.Entity;
  11. namespace EMIS.CommonLogic.ExaminationApply
  12. {
  13. public class ExaminationTypeServices : BaseServices, IExaminationTypeServices
  14. {
  15. public ExaminationTypeDAL ExaminationTypeDAL { get; set; }
  16. /// <summary>
  17. /// 考试类型
  18. /// </summary>
  19. /// <param name="examinationTypeView">实体</param>
  20. /// <param name="pageIndex">当前页码</param>
  21. /// <param name="pageSize">显示页码</param>
  22. /// <returns></returns>
  23. public Bowin.Common.Linq.Entity.IGridResultSet<ExaminationTypeView> GetExaminationTypeViewList(ConfiguretView examinationTypeView, int pageIndex, int pageSize)
  24. {
  25. Expression<Func<EX_ExaminationType, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  26. var q = ExaminationTypeDAL.GetExaminationTypeView(exp);
  27. if (!string.IsNullOrEmpty(examinationTypeView.ConditionValue) && !string.IsNullOrEmpty(examinationTypeView.Attribute))
  28. q = q.DynamicWhere(examinationTypeView.Attribute, examinationTypeView.Condition, examinationTypeView.ConditionValue);
  29. return q.OrderBy(x => x.Name).ToGridResultSet<ExaminationTypeView>(pageIndex, pageSize);
  30. }
  31. /// <summary>
  32. /// 考试类型
  33. /// </summary>
  34. /// <param name="examinationTypeView">实体</param>
  35. /// <returns></returns>
  36. public IList<ExaminationTypeView> GetExaminationTypeViewList(ConfiguretView examinationTypeView)
  37. {
  38. Expression<Func<EX_ExaminationType, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  39. var q = ExaminationTypeDAL.GetExaminationTypeView(exp);
  40. if (!string.IsNullOrEmpty(examinationTypeView.ConditionValue) && !string.IsNullOrEmpty(examinationTypeView.Attribute))
  41. q = q.DynamicWhere(examinationTypeView.Attribute, examinationTypeView.Condition, examinationTypeView.ConditionValue);
  42. return q.OrderBy(x => x.Name).ToList();
  43. }
  44. /// <summary>
  45. /// 根据ID获取考试类型详细信息
  46. /// </summary>
  47. /// <param name="examinationTypeID">考试类型ID</param>
  48. /// <returns></returns>
  49. public ExaminationTypeView GetExaminationTypeViewInfo(Guid? examinationTypeID)
  50. {
  51. return ExaminationTypeDAL.GetExaminationTypeView(x => x.ExaminationTypeID == examinationTypeID).FirstOrDefault();
  52. }
  53. /// <summary>
  54. /// 保存考试类型
  55. /// </summary>
  56. /// <param name="examinationTypeView">考试类型实体</param>
  57. /// <returns></returns>
  58. public void Save(ExaminationTypeView examinationTypeView)
  59. {
  60. var examinationTypeEntity = ExaminationTypeDAL.ExaminationTypeRepository.GetSingle(x => x.ExaminationTypeID == examinationTypeView.ExaminationTypeID);
  61. if (examinationTypeEntity != null)
  62. {
  63. examinationTypeEntity.Name = examinationTypeView.Name;
  64. examinationTypeEntity.IsTimesLimit = examinationTypeView.IsTimesLimit;
  65. this.SetModifyStatus(examinationTypeEntity);
  66. }
  67. else
  68. {
  69. examinationTypeEntity = new EX_ExaminationType();
  70. examinationTypeEntity.ExaminationTypeID = Guid.NewGuid();
  71. examinationTypeEntity.Name = examinationTypeView.Name;
  72. examinationTypeEntity.IsTimesLimit = examinationTypeView.IsTimesLimit;
  73. this.SetNewStatus(examinationTypeEntity);
  74. UnitOfWork.Add(examinationTypeEntity);
  75. }
  76. UnitOfWork.Commit();
  77. }
  78. /// <summary>
  79. /// 删除考试类型
  80. /// </summary>
  81. /// <param name="examinationTypeID">主键ID</param>
  82. /// <returns></returns>
  83. public void Delete(IList<Guid?> examinationTypeID)
  84. {
  85. if (examinationTypeID.Count > 0)
  86. {
  87. UnitOfWork.Delete<EX_ExaminationType>(x => examinationTypeID.Contains(x.ExaminationTypeID));
  88. }
  89. }
  90. public ExaminationTypeView GetView(Expression<Func<EX_ExaminationType, bool>> expCampus)
  91. {
  92. try
  93. {
  94. var query = ExaminationTypeDAL.GetExaminationTypeView(expCampus).FirstOrDefault();
  95. return query;
  96. }
  97. catch (Exception ex)
  98. {
  99. throw new Exception(ex.Message);
  100. }
  101. }
  102. }
  103. }