StudentMinorServices.cs 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using EMIS.ViewModel.MinorManage.MinorApply;
  6. using EMIS.DataLogic.MinorManage.MinorApply;
  7. using System.Linq.Expressions;
  8. using EMIS.Entities;
  9. using Bowin.Common.Linq.Entity;
  10. using EMIS.ViewModel.MinorManage.MinorPlanManage;
  11. using EMIS.DataLogic.MinorManage.MinorPlanManage;
  12. using EMIS.ViewModel;
  13. using Bowin.Common.Linq;
  14. namespace EMIS.CommonLogic.MinorManage.MinorApply
  15. {
  16. public class StudentMinorServices : BaseServices, IStudentMinorServices
  17. {
  18. public StudentMinorDAL studentMinorDAL { get; set; }
  19. public MinorSpecialtyPlanDAL minorSpecialtyPlanDAL { get; set; }
  20. public IMinorApplyServices minorApplyServices { get; set; }
  21. public StudentMinorView GetMinorApplyView(Guid userID)
  22. {
  23. var statusList = minorApplyServices.GetStatusViewList();
  24. Expression<Func<EM_StudentMinorRegist, bool>> exp = x => x.UserID == userID;
  25. if (statusList.Where(y => y.Description.Contains("BP")).FirstOrDefault() != null)
  26. {
  27. var returnStatus = statusList.Where(y => y.Description.Contains("BP")).FirstOrDefault().ID;
  28. exp = exp.And(x => x.RecordStatus != returnStatus);
  29. }
  30. var query = studentMinorDAL.GetStudentMinorViewQueryable(exp).FirstOrDefault();
  31. if (query != null)
  32. {
  33. query.RecordStatusStr = statusList.FirstOrDefault(w => w.ID == query.RecordStatus).Name;
  34. }
  35. return query;
  36. }
  37. public IGridResultSet<MinorSpecialtyPlanView> GetMinorSpecialtyViewByUserIDGrid(Guid userID, int? pageIndex, int? pageSize)
  38. {
  39. Expression<Func<EM_MinorPlan, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  40. var grademinorID = studentMinorDAL.GetGrademinorIDByUserID(userID);
  41. exp = exp.And(x => x.GrademinorID == grademinorID);
  42. var query = minorSpecialtyPlanDAL.GetMinorSpecialtyPlanViewQueryable(exp);
  43. var result = this.GetQueryByDataRangeByCollege(query).OrderBy(x => x.StandardID).ThenBy(x => x.SchoolcodeStr)
  44. .ToGridResultSet<MinorSpecialtyPlanView>(pageIndex, pageSize);
  45. return result;
  46. }
  47. public void StudentMinorCancel(Guid? userID, Guid? studentMinorRegistID)
  48. {
  49. try
  50. {
  51. var grademinor = studentMinorDAL.grademinorRepository.GetSingle(x => x.EM_StudentMinorRegist.Any(y => y.StudentMinorRegistID == studentMinorRegistID));
  52. if(grademinor != null)
  53. {
  54. if (grademinor.RecordStatus == (int)CF_GrademinorStatus.Confirmed)
  55. {
  56. throw new Exception("报名的辅修专业已开班,不能取消报名");
  57. }
  58. }
  59. if (studentMinorDAL.classminorStudentRepository.Entities.Any(x => x.UserID == userID))
  60. {
  61. UnitOfWork.Delete<CF_ClassminorStudent>(x => x.UserID == userID);
  62. }
  63. UnitOfWork.Delete<EM_StudentMinorRegist>(x => x.StudentMinorRegistID == studentMinorRegistID);
  64. UnitOfWork.Commit();
  65. }
  66. catch (Exception)
  67. {
  68. throw;
  69. }
  70. }
  71. }
  72. }