using System; using System.Collections.Generic; using System.Linq; using System.Text; using EMIS.DataLogic.Repositories; using System.Linq.Expressions; using EMIS.Entities; using EMIS.ViewModel.MinorManage.MinorClass; using EMIS.ViewModel.MinorManage.MinorApply; using EMIS.ViewModel.Students; namespace EMIS.DataLogic.MinorManage.MinorClass { public class MinorClassDAL { public ClassminorRepository classminorRepository { get; set; } public GrademinorRepository grademinorRepository { get; set; } public SchoolyearRepository schoolyearRepository { get; set; } public CollegeRepository collegeRepository { get; set; } public StudentRepository studentRepository { get; set; } public ClassmajorRepository classmajorRepository { get; set; } public GrademajorRepository grademajorRepository { get; set; } public FacultymajorRepository facultymajorRepository { get; set; } public StudentMinorRegistRepository studentMinorRegistRepository { get; set; } public GrademinorApplicationRepository grademinorApplicationRepository { get; set; } public DictionaryItemRepository dictionaryItemRepository { get; set; } public ClassminorStudentRepository classminorStudentRepository { get; set; } public UserRepository userRepository { get; set; } public IQueryable GetMinorClassViewQueryable(Expression> exp, Expression> expgm) { var query = from cr in classminorRepository.GetList(exp) join gr in grademinorRepository.GetList(expgm) on cr.GrademinorID equals gr.GrademinorID join sr in schoolyearRepository.Entities on gr.SchoolyearID equals sr.SchoolyearID join col in collegeRepository.Entities on gr.CollegeID equals col.CollegeID select new MinorClassView { ClassminorID = cr.ClassminorID, GrademinorID = cr.GrademinorID, SchoolyearID = gr.SchoolyearID, SchoolyearCode = sr.Code, GradeYearID = gr.YearID, StandardID = gr.StandardID, Name = cr.Name, StudentNum = cr.CF_ClassminorStudent.Count, CF_ClassminorStudent = cr.CF_ClassminorStudent, RecordStatus = cr.RecordStatus }; return query; } public IQueryable GetStudentsQueryable(Expression> exp) { var query = from clastu in classminorStudentRepository.GetList(exp) join user in userRepository.Entities on clastu.UserID equals user.UserID join stu in studentRepository.Entities on clastu.UserID equals stu.UserID join cla in classmajorRepository.Entities on stu.ClassmajorID equals cla.ClassmajorID join gra in grademajorRepository.Entities on cla.GrademajorID equals gra.GrademajorID join fac in facultymajorRepository.Entities on gra.FacultymajorID equals fac.FacultymajorID join col in collegeRepository.Entities on fac.CollegeID equals col.CollegeID select new StudentsView { CollegeID = col.CollegeID, CollegeName = col.Name, CollegeCode = col.No, GradeMajorID = gra.GrademajorID, GradeMajorCode = gra.Code, GradeMajorName = gra.Name, ClassMajorID = cla.GrademajorID, ClassMajorName = cla.Name, ClassMajorCode = cla.No, LoginID = user.LoginID, UserName = user.Name, UserID = user.UserID, }; return query; } public IQueryable GetGrademinor() { var query = from gr in grademinorRepository.Entities select new CF_Grademinor { GrademinorID = gr.GrademinorID, SchoolyearID = gr.SchoolyearID, CollegeID = gr.CollegeID, YearID = gr.YearID, }; return query; } } }