StudentMinorDAL.cs 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using EMIS.ViewModel.MinorManage.MinorApply;
  6. using System.Linq.Expressions;
  7. using EMIS.Entities;
  8. using EMIS.DataLogic.Repositories;
  9. namespace EMIS.DataLogic.MinorManage.MinorApply
  10. {
  11. public class StudentMinorDAL
  12. {
  13. public StudentMinorRegistRepository studentMinorRegistRepository { get; set; }
  14. public UserRepository userRepository { get; set; }
  15. public GrademinorRepository grademinorRepository { get; set; }
  16. public CollegeRepository collegeRepository { get; set; }
  17. public DictionaryItemRepository dictionaryItemRepository { get; set; }
  18. public ClassminorStudentRepository classminorStudentRepository { get; set; }
  19. public ClassminorRepository classminorRepository { get; set; }
  20. public IQueryable<StudentMinorView> GetStudentMinorViewQueryable(Expression<Func<EM_StudentMinorRegist, bool>> exp)
  21. {
  22. var query = from smrr in studentMinorRegistRepository.GetList(exp)
  23. join user in userRepository.Entities
  24. on smrr.UserID equals user.UserID
  25. join gra in grademinorRepository.Entities
  26. on smrr.GrademinorID equals gra.GrademinorID
  27. join dic in dictionaryItemRepository.GetList(x => x.DictionaryCode == "CF_Standard")
  28. on gra.StandardID equals dic.Value
  29. join col in collegeRepository.Entities
  30. on gra.CollegeID equals col.CollegeID
  31. select new StudentMinorView
  32. {
  33. StudentMinorRegistID = smrr.StudentMinorRegistID,
  34. UserID = smrr.UserID,
  35. UserName = user.Name,
  36. LoginID = user.LoginID,
  37. GradeYearID = gra.YearID,
  38. CollegeID = gra.CollegeID,
  39. CollegeCode = col.No,
  40. CollegeName = col.Name,
  41. GrademinorID = gra.GrademinorID,
  42. GrademinorCode = dic.Code,
  43. GrademinorName = dic.Name,
  44. RecordStatus = smrr.RecordStatus,
  45. };
  46. return query;
  47. }
  48. public Guid? GetGrademinorIDByUserID(Guid userID)
  49. {
  50. var query = from csr in classminorStudentRepository.GetList(x => x.UserID == userID)
  51. join cr in classminorRepository.Entities
  52. on csr.ClassminorID equals cr.ClassminorID
  53. select new
  54. {
  55. GrademinorID = cr.GrademinorID
  56. };
  57. if (query.FirstOrDefault() != null)
  58. {
  59. return query.FirstOrDefault().GrademinorID;
  60. }
  61. return null;
  62. }
  63. }
  64. }