ScoreConvertByApplyDAL.cs 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Linq.Expressions;
  6. using EMIS.Entities;
  7. using EMIS.ViewModel.ScoreManage;
  8. using EMIS.DataLogic.Repositories;
  9. using EMIS.ViewModel;
  10. namespace EMIS.DataLogic.ScoreManage
  11. {
  12. public class ScoreConvertByApplyDAL
  13. {
  14. public ScoreConvertByApplyRepository scoreConvertByApplyRepository { get; set; }
  15. public CollegeRepository CollegeRepository { get; set; }
  16. public FacultymajorRepository FacultymajorRepository { get; set; }
  17. public GrademajorRepository GrademajorRepository { get; set; }
  18. public ClassmajorRepository ClassmajorRepository { get; set; }
  19. public StudentRepository StudentRepository { get; set; }
  20. public UserRepository UserRepository { get; set; }
  21. public SchoolyearRepository SchoolyearRepository { get; set; }
  22. public CoursematerialRepository CoursematerialRepository { get; set; }
  23. public GradePointFormulaRepository gradePointFormulaRepository { get; set; }
  24. public ScoreParameterSettingRepository scoreParameterSettingRepository { get; set; }
  25. public IQueryable<ScoreConvertByApplyView> GetScoreConvertByApplyViewQueryable(Expression<Func<ER_ScoreConvertByApply, bool>> exp,
  26. Expression<Func<CF_Facultymajor, bool>> facultyExp,
  27. Expression<Func<CF_Grademajor, bool>> gradeExp,
  28. Expression<Func<CF_Classmajor, bool>> classExp)
  29. {
  30. var query = from scbyapp in scoreConvertByApplyRepository.GetList(exp)
  31. join user in UserRepository.Entities on scbyapp.UserID equals user.UserID
  32. join stu in StudentRepository.Entities on user.UserID equals stu.UserID
  33. join cla in ClassmajorRepository.GetList(classExp) on stu.ClassmajorID equals cla.ClassmajorID
  34. join gra in GrademajorRepository.GetList(gradeExp) on cla.GrademajorID equals gra.GrademajorID
  35. join fac in FacultymajorRepository.GetList(facultyExp) on gra.FacultymajorID equals fac.FacultymajorID
  36. join col in CollegeRepository.Entities on fac.CollegeID equals col.CollegeID
  37. join sch in SchoolyearRepository.Entities on scbyapp.SchoolyearID equals sch.SchoolyearID
  38. join cou in CoursematerialRepository.Entities on scbyapp.CoursematerialID equals cou.CoursematerialID
  39. select new ScoreConvertByApplyView
  40. {
  41. ScoreConvertByApplyID = scbyapp.ScoreConvertByApplyID,
  42. SchoolyearID = scbyapp.SchoolyearID,
  43. SchoolyearCode = sch.Code,
  44. CollegeID = col.CollegeID,
  45. CollegeNo = col.No,
  46. CollegeName = col.Name,
  47. StandardID = fac.StandardID,
  48. ClassmajorID = cla.ClassmajorID,
  49. ClassmajorNo = cla.No,
  50. ClassmajorName = cla.Name,
  51. UserID = scbyapp.UserID,
  52. LoginID = user.LoginID,
  53. Name = user.Name,
  54. CoursematerialID = cou.CoursematerialID,
  55. CourseCode = cou.CourseCode,
  56. CourseName = cou.CourseName,
  57. TotalScore = scbyapp.TotalScore,
  58. RecordStatus = scbyapp.RecordStatus,
  59. Reason = scbyapp.Reason,
  60. AttachmentList = scbyapp.ER_ScoreConvertByApplyAttachment,
  61. };
  62. return query;
  63. }
  64. public IOrderedQueryable<FileUploadView> GetScoreConvertByApplyAttachmentView(Expression<Func<ER_ScoreConvertByApply, bool>> exp)
  65. {
  66. var tableName = typeof(ER_ScoreConvertByApplyAttachment).Name;
  67. var sql = (from @group in scoreConvertByApplyRepository.GetList(exp)
  68. from attachment in @group.ER_ScoreConvertByApplyAttachment
  69. orderby attachment.CreateTime descending
  70. select new FileUploadView
  71. {
  72. FileID = attachment.ScoreConvertByApplyAttachmentID,
  73. FileName = attachment.Name,
  74. FileUrl = attachment.Url,
  75. FormID = attachment.ScoreConvertByApplyID,
  76. TableName = tableName
  77. });
  78. return (IOrderedQueryable<FileUploadView>)sql;
  79. }
  80. public IQueryable<GradePointFormulaView> GetDefaultGradePointFormula()
  81. {
  82. var query = from par in scoreParameterSettingRepository.Entities.Where(x => x.ExamsTypeID == (int)SYS_ExamsType.CommonSettings)
  83. join gra in gradePointFormulaRepository.Entities
  84. on par.GradePointFormulaID equals gra.GradePointFormulaID
  85. select new GradePointFormulaView
  86. {
  87. GradePointFormulaID = gra.GradePointFormulaID,
  88. GradePointlimit = gra.GradePointlimit,
  89. GradePointFloor = gra.GradePointFloor,
  90. Name = gra.Name
  91. };
  92. return query;
  93. }
  94. }
  95. }