ExamPersonControlServices.cs 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using Bowin.Common.Linq.Entity;
  6. using EMIS.Entities;
  7. using EMIS.DataLogic.ExamManage;
  8. using System.Linq.Expressions;
  9. using EMIS.DataLogic;
  10. using EMIS.ViewModel.Students;
  11. namespace EMIS.CommonLogic.ExamManage
  12. {
  13. public class ExamPersonControlServices : BaseServices, IExamPersonControlServices
  14. {
  15. public ExamPersonControlDAL Logic { get; set; }
  16. public Bowin.Common.Linq.Entity.IGridResultSet<ViewModel.ExamPersonControlView> GetListGridView(int pageIndex, int pageSize, params ViewModel.ConfiguretView[] configuretViews)
  17. {
  18. System.Linq.Expressions.Expression<Func<EX_ExaminationBatchProjectPersonControl, bool>> expCampus = (x => true);
  19. var query = Logic.GetList(expCampus);
  20. //查询条件
  21. foreach (var configuretView in configuretViews)
  22. {
  23. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  24. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  25. }
  26. return query.OrderByDescending(x => x.Schoolyear)
  27. .OrderBy(x => x.ExaminationBatchProjectPersonControlID)
  28. .ToGridResultSet<EMIS.ViewModel.ExamPersonControlView>(pageIndex, pageSize);
  29. }
  30. public IGridResultSet<EMIS.ViewModel.ExaminationApply.ExaminationTypeView> GetControlExamTypeListViewGrid(int pageIndex, int pageSize, params EMIS.ViewModel.ConfiguretView[] configuretViews)
  31. {
  32. System.Linq.Expressions.Expression<Func<EX_ExaminationBatchProjectPersonControl, bool>> expCampus = (x => true);
  33. var query = Logic.GetList(expCampus);
  34. //查询条件
  35. foreach (var configuretView in configuretViews)
  36. {
  37. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  38. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  39. }
  40. var result = query.OrderBy(x => x.ExaminationBatchProjectID).GroupBy(x => new
  41. {
  42. x.ExaminationBatchID,
  43. x.ExaminationTypeID,
  44. x.ExaminationType
  45. }).Select(x => new EMIS.ViewModel.ExaminationApply.ExaminationTypeView()
  46. {
  47. ExaminationBatchID = x.Key.ExaminationBatchID.Value,
  48. ExaminationTypeID = x.Key.ExaminationTypeID.Value,
  49. Name = x.Key.ExaminationType
  50. });
  51. return result
  52. .OrderBy(x => x.ExaminationBatchID)
  53. .ToGridResultSet<EMIS.ViewModel.ExaminationApply.ExaminationTypeView>(pageIndex, pageSize);
  54. }
  55. public IGridResultSet<EMIS.ViewModel.ExamBatchProjectView> GetControlProjectListViewGrid(int pageIndex, int pageSize, params EMIS.ViewModel.ConfiguretView[] configuretViews)
  56. {
  57. System.Linq.Expressions.Expression<Func<EX_ExaminationBatchProjectPersonControl, bool>> expCampus = (x => true);
  58. var query = Logic.GetList(expCampus);
  59. //查询条件
  60. foreach (var configuretView in configuretViews)
  61. {
  62. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  63. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  64. }
  65. var result = query.OrderBy(x => x.ExaminationBatchProjectID).GroupBy(x => new
  66. {
  67. x.ExaminationBatchID,
  68. x.ExaminationTypeID,
  69. x.ExaminationBatchProjectID,
  70. x.ProjectName
  71. }).Select(x => new EMIS.ViewModel.ExamBatchProjectView()
  72. {
  73. ExaminationBatchID = x.Key.ExaminationBatchID.Value,
  74. ExaminationTypeID = x.Key.ExaminationTypeID.Value,
  75. Name = x.Key.ProjectName,
  76. ExaminationBatchProjectID = x.Key.ExaminationBatchProjectID.Value,
  77. });
  78. return result
  79. .OrderBy(x => x.ExaminationBatchID)
  80. .ToGridResultSet<EMIS.ViewModel.ExamBatchProjectView>(pageIndex, pageSize);
  81. }
  82. public ViewModel.ExamPersonControlView GetView(Guid? ViewID)
  83. {
  84. var query = Logic.GetList(x => x.ExaminationBatchProjectPersonControlID == ViewID).SingleOrDefault();
  85. return query;
  86. }
  87. public void Edit(ViewModel.ExamPersonControlView view, List<StudentsView> studentsViewList)
  88. {
  89. //UnitOfWork.Delete<EX_ExaminationBatchProjectPersonControl>(q => q.ExaminationBatchProjectID == view.ExaminationBatchProjectID);
  90. var examinationBatchProject = Logic.BatchProjectRepository.Entities.Where(x => x.ExaminationBatchID == view.ExaminationBatchID && x.ExaminationProjectID == view.ExaminationProjectID).FirstOrDefault();
  91. var PersonControlList = Logic.PersonControlRepository.Entities.Where(x => x.ExaminationBatchProjectID == examinationBatchProject.ExaminationBatchProjectID).ToList();
  92. foreach (var student in studentsViewList)
  93. {
  94. var entity = PersonControlList.Where(x => x.UserID == student.UserID).FirstOrDefault();
  95. if (entity == null)
  96. {
  97. entity = new EX_ExaminationBatchProjectPersonControl();
  98. entity.ExaminationBatchProjectPersonControlID = Guid.NewGuid();
  99. this.SetNewStatus(entity);
  100. Logic.PersonControlRepository.UnitOfWork.Add(entity);
  101. }
  102. entity.ExaminationBatchProjectID = examinationBatchProject.ExaminationBatchProjectID;
  103. entity.ExaminationProjectFeeID = view.ExaminationProjectFeeID;
  104. entity.UserID = student.UserID;
  105. entity.IsOnlinePay = view.IsOnlinePay;
  106. entity.EndDate = view.EndDate;
  107. entity.StartDate = view.StartDate;
  108. this.SetModifyStatus(entity);
  109. }
  110. Logic.PersonControlRepository.UnitOfWork.Commit();
  111. }
  112. public ViewModel.ExamPersonControlView GetView(System.Linq.Expressions.Expression<Func<Entities.EX_ExaminationBatchProjectPersonControl, bool>> expCampus)
  113. {
  114. var query = Logic.GetList(expCampus).SingleOrDefault();
  115. return query;
  116. }
  117. public IQueryable<ViewModel.ExamPersonControlView> GetList(params ViewModel.ConfiguretView[] configuretViews)
  118. {
  119. System.Linq.Expressions.Expression<Func<EX_ExaminationBatchProjectPersonControl, bool>> expCampus = (x => true);
  120. var query = Logic.GetList(expCampus);
  121. //查询条件
  122. foreach (var configuretView in configuretViews)
  123. {
  124. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  125. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  126. }
  127. return query
  128. .OrderBy(x => x.ExaminationBatchProjectPersonControlID);
  129. }
  130. public bool Delete(List<Guid?> IDs)
  131. {
  132. UnitOfWork.Delete<EX_ExaminationBatchProjectPersonControl>(x => IDs.Contains(x.ExaminationBatchProjectPersonControlID));
  133. UnitOfWork.Commit();
  134. return true;
  135. }
  136. }
  137. }