private void SetDropdowns(ProvisioningRulesViewModel model) { var sy = DateTime.Now.GetSchoolYear(); model.Years = new List <SelectListItem> { new SelectListItem { Text = string.Format("{0}-{1}", sy - 1, sy), Value = sy.ToString() }, new SelectListItem { Text = string.Format("{0}-{1}", sy, sy + 1), Value = (sy + 1).ToString() } }; model.Categories = _orgBusiness.GetSchoolCategoriesForLea(model.SchoolYear, model.EducationOrganizationId).Select(c => new SelectListItem { Text = c.ShortDescription, Value = c.DescriptorId.ToString() }).ToList(); model.Schools = _orgBusiness.GetSchoolsForLea(model.SchoolYear, model.EducationOrganizationId, model.SchoolCategoryDescriptorId).Select(c => new SelectListItem { Text = c.EducationOrganization.NameOfInstitution, Value = c.SchoolId.ToString() }).ToList(); model.Schools.Insert(0, item: new SelectListItem { Text = "All Schools", Value = "" }); model.Sessions = _rosterBusiness.GetSessions(model.SchoolYear, model.EducationOrganizationId, model.SchoolCategoryDescriptorId, model.SelectedSchools).Select(c => new SelectListItem { Text = c, Value = c }).ToList(); model.Courses = _rosterBusiness.GetCourseTitles(model.SchoolYear, model.EducationOrganizationId, model.SchoolCategoryDescriptorId, model.SelectedSchools, model.SelectedSession).Select(c => new SelectListItem { Text = c.CourseCode + " - " + c.CourseTitle, Value = c.CourseCode }).ToList(); model.Courses.Insert(0, item: new SelectListItem { Text = "All Courses", Value = "" }); model.Grades = _rosterBusiness.GetGrades(model.SchoolYear, model.EducationOrganizationId, model.SchoolCategoryDescriptorId, model.SelectedSchools).Select(c => new SelectListItem { Text = c.ShortDescription, Value = c.DescriptorId.ToString() }).ToList(); model.Teachers = _rosterBusiness.GetStaff(model.SchoolYear, model.EducationOrganizationId, model.SchoolCategoryDescriptorId, model.SelectedSchools, model.SelectedSession).Select(c => new SelectListItem { Text = c.FirstName + " " + c.LastSurname, Value = c.StaffUsi.ToString() }).ToList(); model.CoursesByTeacher = _rosterBusiness.GetCourseTitlesByTeacher(model.SchoolYear, model.EducationOrganizationId, model.SchoolCategoryDescriptorId, model.SelectedSchools, model.SelectedSession, model.SelectedTeacher).Select(c => new SelectListItem { Text = c.CourseCode + " - " + c.CourseTitle, Value = c.CourseCode }).ToList(); model.CoursesByTeacher.Insert(0, item: new SelectListItem { Text = "All Courses", Value = "" }); }
public ActionResult Preview(short?schoolYear, int?schoolId) { var model = new SyncViewModel(); var lea = _sessionInfo.CurrentAgencyId.GetValueOrDefault(); short sy = DateTime.Now.GetSchoolYear(); if (schoolYear == null) { if (HttpContext.Session["SchoolYear"] != null) { schoolYear = short.Parse(HttpContext.Session["SchoolYear"].ToString()); } else { schoolYear = sy; } } else { HttpContext.Session["SchoolYear"] = schoolYear; } model.SchoolYear = schoolYear.GetValueOrDefault(); model.Years = new List <SelectListItem> { new SelectListItem { Text = string.Format("{0}-{1}", sy - 1, sy), Value = sy.ToString() }, new SelectListItem { Text = string.Format("{0}-{1}", sy, sy + 1), Value = (sy + 1).ToString() } }; model.Schools = _orgBusiness.GetSchoolsForLea(schoolYear.GetValueOrDefault(), lea, null).Select(c => new SelectListItem { Text = c.EducationOrganization.NameOfInstitution, Value = c.SchoolId.ToString() }).ToList(); if (schoolId == null) { int.TryParse(model.Schools.Select(v => v.Value).FirstOrDefault(), out var school); schoolId = school; } model.SelectedSchool = schoolId.GetValueOrDefault(); model.SyncList = _provisioningRuleBusiness.GetSyncList(lea, schoolYear.GetValueOrDefault(), schoolId.GetValueOrDefault()); return(View(model)); }