TeacherEvaluationServices.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using EMIS.DataLogic.Common.EvaluationManage;
  6. using Bowin.Common.Linq.Entity;
  7. using EMIS.ViewModel.EvaluationManage;
  8. using EMIS.ViewModel;
  9. using System.Linq.Expressions;
  10. using EMIS.Entities;
  11. using Bowin.Common.Linq;
  12. using Bowin.Common.Utility;
  13. using Bowin.Common.Mapping;
  14. using EMIS.CommonLogic.SystemServices;
  15. namespace EMIS.CommonLogic.EvaluationManage
  16. {
  17. public class TeacherEvaluationServices : BaseServices, ITeacherEvaluationServices
  18. {
  19. public TeacherEvaluationDAL TeacherEvaluationDAL { get; set; }
  20. public ISerialNumberServices SerialNumberServices { get; set; }
  21. public IGridResultSet<TeacherEvaluationView> GetTeacherEvaluationViewGrid(ConfiguretView configuretView, Guid? schoolYearID, Guid? campusID, Guid? collegeID, int? openStatus, int pageIndex, int pageSize)
  22. {
  23. Expression<Func<EM_TeacherEvaluation, bool>> filter = w => w.RecordStatus == (int)SYS_STATUS.USABLE;
  24. if (openStatus.HasValue && openStatus != -1)
  25. {
  26. filter = filter.And(w => w.OpenStatus == openStatus);
  27. }
  28. var query = TeacherEvaluationDAL.GetTeacherEvaluationQuery(filter);
  29. if (schoolYearID.HasValue && schoolYearID != Guid.Empty)
  30. {
  31. query.Where(w => w.SchoolyearID == schoolYearID);
  32. }
  33. if (campusID.HasValue && campusID != Guid.Empty)
  34. {
  35. query.Where(w => w.CampusID == campusID);
  36. }
  37. if (collegeID.HasValue && collegeID != Guid.Empty)
  38. {
  39. query.Where(w => w.CollegeID == collegeID);
  40. }
  41. query = GetQueryByDataRangeByCollege(query);
  42. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  43. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue);
  44. query = query.OrderByDescending(o => o.EntityCreateTime);
  45. return query.ToGridResultSet(pageIndex, pageSize);
  46. }
  47. public TeacherEvaluationView GetTeacherEvaluationView(Guid? id)
  48. {
  49. var result = new TeacherEvaluationView();
  50. if (id.HasValue && id != Guid.Empty)
  51. result = TeacherEvaluationDAL.GetTeacherEvaluationQuery(w => w.ID == id).FirstOrDefault();
  52. return result;
  53. }
  54. public void AddOrUpdateTeacherEvaluation(TeacherEvaluationView model)
  55. {
  56. EM_TeacherEvaluation entity;
  57. if (model.EntityID == Guid.Empty)
  58. {
  59. entity = new EM_TeacherEvaluation();
  60. model.DynamicCloneTo(entity);
  61. //SetNewStatus方法去掉了设置ID的功能
  62. entity.ID = Guid.NewGuid();
  63. SetNewStatus(entity);
  64. entity.Code = SerialNumberServices.SetSN(model.CourseCode + "(" + model.SchoolyearCode + ")");
  65. entity.CreateTime = DateTime.Now;
  66. UnitOfWork.Add(entity);
  67. }
  68. else
  69. {
  70. entity = TeacherEvaluationDAL.TeacherEvaluationRepository.GetSingle(w => w.ID == model.EntityID);
  71. model.DynamicCloneTo(entity);
  72. SetModifyStatus(entity);
  73. UnitOfWork.Update(entity);
  74. }
  75. UnitOfWork.Commit();
  76. }
  77. public void DeleteTeacherEvaluation(List<Guid> ids)
  78. {
  79. UnitOfWork.Delete<EM_TeacherEvaluation>(w => ids.Contains(w.ID));
  80. }
  81. }
  82. }