internal EmployeeDirectoryTeachersViewModel GetViewModel_Internal() { var viewModel = new EmployeeDirectoryTeachersViewModel(); var eduProgramProfiles = new EduProgramProfileQuery(ModelContext).ListByEduLevels(Settings.EduLevels) .Select(epp => new EduProgramProfileViewModel(epp, viewModel)) .ToList(); if (Settings.ShowAllTeachers) { eduProgramProfiles.Add(new EduProgramProfileViewModel( new EduProgramProfileInfo { EduProgramProfileID = Null.NullInteger, EduProgram = new EduProgramInfo { Code = string.Empty, Title = LocalizeString("NoDisciplines.Text") } }, viewModel) ); } if (eduProgramProfiles.Count > 0) { var teachers = new TeachersQuery(ModelContext).List(); IEnumerable <IEmployee> eduProgramProfileTeachers; foreach (var eduProgramProfile in eduProgramProfiles) { if (!Null.IsNull(eduProgramProfile.EduProgramProfileID)) { eduProgramProfileTeachers = teachers .Where(t => t.Disciplines.Any( d => d.EduProgramProfileID == eduProgramProfile.EduProgramProfileID)); } else { // get teachers w/o disciplines eduProgramProfileTeachers = teachers .Where(t => t.Disciplines.IsNullOrEmpty()); } var indexer = new ViewModelIndexer(1); eduProgramProfile.Teachers = new IndexedEnumerable <TeacherViewModel> (indexer, eduProgramProfileTeachers .OrderBy(t => t.LastName) .ThenBy(t => t.FirstName) .Select(t => new TeacherViewModel(t, eduProgramProfile, viewModel, indexer)) ); } } viewModel.EduProgramProfiles = eduProgramProfiles; return(viewModel); }
void BindEduProgramProfiles(int eduLevelId) { using (var modelContext = new UniversityModelContext()) { var epps = new EduProgramProfileQuery(modelContext).ListByEduLevel(eduLevelId) .Select(epp => new EduProgramProfileViewModel(epp)) .OrderBy(epp => epp.EduProgram.Code) .ThenBy(epp => epp.EduProgram.Title) .ThenBy(epp => epp.ProfileCode) .ThenBy(epp => epp.ProfileTitle); comboEduProgramProfile.DataSource = epps; comboEduProgramProfile.DataBind(); } }
internal EduProgramProfileDirectoryDocumentsViewModel GetDocumentsViewModel_Internal() { var viewModel = new EduProgramProfileDirectoryDocumentsViewModel(); var indexer = new ViewModelIndexer(1); var eduProgramProfiles = new EduProgramProfileQuery(ModelContext) .ListWithDocuments(Settings.EduLevelIds, Settings.DivisionId, Settings.DivisionLevel); viewModel.EduProgramProfiles = new IndexedEnumerable <EduProgramProfileDocumentsViewModel> (indexer, eduProgramProfiles.Select(epp => new EduProgramProfileDocumentsViewModel(epp, viewModel, indexer)) ); return(viewModel); }
protected override void OnUpdateItem(EmployeeDisciplineEditModel item) { item.EduProgramProfileID = int.Parse(comboEduProgramProfile.SelectedValue); item.Disciplines = textDisciplines.Text.Trim(); using (var modelContext = new UniversityModelContext()) { var profile = new EduProgramProfileQuery(modelContext).SingleOrDefault(item.EduProgramProfileID); item.Code = profile.EduProgram.Code; item.Title = profile.EduProgram.Title; item.ProfileCode = profile.ProfileCode; item.ProfileTitle = profile.ProfileTitle; item.ProfileStartDate = profile.StartDate; item.ProfileEndDate = profile.EndDate; item.EduLevelString = FormatHelper.FormatShortTitle(profile.EduLevel.ShortTitle, profile.EduLevel.Title); } }
protected override void OnLoadItem(EmployeeDisciplineEditModel item) { using (var modelContext = new UniversityModelContext()) { var profile = new EduProgramProfileQuery(modelContext).SingleOrDefault(item.EduProgramProfileID); var eduLevelId = int.Parse(comboEduLevel.SelectedValue); var newEduLevelId = profile.EduLevelId; if (eduLevelId != newEduLevelId) { comboEduLevel.SelectByValue(newEduLevelId); BindEduProgramProfiles(newEduLevelId); } comboEduProgramProfile.SelectByValue(item.EduProgramProfileID); textDisciplines.Text = item.Disciplines; hiddenEduProgramProfileID.Value = item.EduProgramProfileID.ToString(); } }