using EMIS.DataLogic.Repositories; using EMIS.Entities; using EMIS.ViewModel.ExamManage; using System; using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; using System.Text; namespace EMIS.DataLogic.ExamManage { public class LevelSettingSubjectDAL { public LevelSettingRepository levelSettingRepository { get; set; } public ExaminationProjectRepository examinationProjectRepository { get; set; } public ExaminationTypeRepository examinationTypeRepository { get; set; } public LevelSettingSubjectRepository levelSettingSubjectRepository { get; set; } public DictionaryItemRepository dictionaryItemRepository { get; set; } public ProjectScoreRepository projectScoreRepository { get; set; } public ExaminationProjectSubjectRepository examinationProjectSubjectRepository { get; set; } public IQueryable GetLevelSettingView(Expression> erexp) { var query = from level in levelSettingRepository.Entities from epr in examinationProjectRepository.Entities.Where(erexp).Where(x => x.ExaminationProjectID == level.ExaminationProjectID) from etr in examinationTypeRepository.Entities.Where(x => x.ExaminationTypeID == epr.ExaminationTypeID) select new LevelSettingView { LevelSettingID = level.LevelSettingID, LevelName = level.LevelName, ExaminationProjectID = level.ExaminationProjectID, ExaminationProjectName = epr.Name, ExaminationTypeID = epr.ExaminationTypeID, ExaminationTypeName = etr.Name, IsPassed = level.IsPassed, IsPassedEdit = level.IsPassed.Value, IsPassLine = level.IsPassLine, IsPassLineEdit = level.IsPassLine.Value, RecordStatus = level.RecordStatus, }; return query; } public IQueryable GetLevelSettingSubjectViewByLevelID(Guid? levelSettingID) { var query = from level in levelSettingRepository.Entities.Where(x => x.LevelSettingID == levelSettingID) from lssr in levelSettingSubjectRepository.Entities.Where(x => x.LevelSettingID == level.LevelSettingID) from epr in examinationProjectRepository.Entities.Where(x => x.ExaminationProjectID == level.ExaminationProjectID) from etr in examinationTypeRepository.Entities.Where(x => x.ExaminationTypeID == epr.ExaminationTypeID) select new LevelSettingSubjectView { LevelSettingID = level.LevelSettingID, ExaminationSubjectID = lssr.ExaminationSubjectID, PassScore = lssr.PassScore }; return query; } public LevelSettingView GetLevelSettingSubjectView(Guid? levelSettingID) { var query = from level in levelSettingRepository.Entities.Where(x => x.LevelSettingID == levelSettingID) from epr in examinationProjectRepository.Entities.Where(x => x.ExaminationProjectID == level.ExaminationProjectID) from etr in examinationTypeRepository.Entities.Where(x => x.ExaminationTypeID == epr.ExaminationTypeID) select new LevelSettingView { LevelSettingID = level.LevelSettingID, LevelName = level.LevelName, ExaminationProjectID = level.ExaminationProjectID, ExaminationProjectName = epr.Name, ExaminationTypeID = epr.ExaminationTypeID, ExaminationTypeName = etr.Name, IsPassed = level.IsPassed, IsPassedEdit = level.IsPassed.Value, IsPassLine = level.IsPassLine, IsPassLineEdit = level.IsPassLine.Value, RecordStatus = level.RecordStatus, }; return query.FirstOrDefault(); } public IQueryable GetLevelSettingSubjectViewByProjectID(Guid? examinationProjectID) { var query = from dic in dictionaryItemRepository.Entities.Where(x => x.DictionaryCode == "EX_ExaminationSubject") select new LevelSettingSubjectView { ExaminationSubjectID = dic.Value, }; if (examinationProjectID.HasValue) { query = from level in levelSettingRepository.Entities.Where(x => x.ExaminationProjectID == examinationProjectID) from lssr in levelSettingSubjectRepository.Entities.Where(x => x.LevelSettingID == level.LevelSettingID) select new LevelSettingSubjectView { LevelSettingID = level.LevelSettingID, ExaminationSubjectID = lssr.ExaminationSubjectID, PassScore = lssr.PassScore }; } return query.Distinct(); } } }