public void PopulateViewData(StudentExt studentExt) { dbTIREntities db = new dbTIREntities(); SiteUser siteUser = ((SiteUser)Session["SiteUser"]); StudentService studentService = new StudentService(siteUser, db); ModelServices modelService = new ModelServices(); studentExt.DistrictId = siteUser.Districts[0].Id; studentExt.DistrictDesc = siteUser.Districts[0].Name; studentExt.StudentClasses = studentExt.StudentId != 0 ? modelService.GetClassesByStudent(studentExt.StudentId, studentExt.SchoolYear) : null; studentExt.SchoolYears = studentExt.StudentId != 0 ? modelService.GetSchoolYearByStudent(studentExt.StudentId) : null; studentExt.DropDown = new DropDownData(); int schoolYearId = modelService.GetSchoolYearId(studentExt.SchoolYear); studentExt.DropDown.School = new SchoolDropDown(modelService.GetSchoolDropDownData(siteUser.EdsUserId, schoolYearId), false); studentExt.DropDown.School.SelectedSchool = studentExt.ServingSchoolId; studentExt.DropDown.Grade = new GradeDropDown(studentService.DropDownDataForGrade()); studentExt.DropDown.Grade.SelectedGrade = (studentExt.GradeLevel != null) ? (int)studentExt.GradeLevel : -1; studentExt.DropDown.Gender = new GenderDropDown(modelService.DropDownDataForGender()); studentExt.DropDown.Gender.SelectedGender = (studentExt.GenderId != null) ? (int)studentExt.GenderId : 1; studentExt.DropDown.Lineage = new LineageDropDown(studentService.DropDownDataForLineage()); studentExt.DropDown.Lineage.SelectedLineage = (studentExt.LineageId != null) ? (int)studentExt.LineageId : -1; studentExt.DropDown.HomeLanguage = new LanguageDropDown(studentService.DropDownDataForLanguage()); studentExt.DropDown.HomeLanguage.SelectedLanguage = (studentExt.HomeLanguageId != null) ? (int)studentExt.HomeLanguageId : -1; studentExt.DropDown.NativeLanguage = new LanguageDropDown(studentService.DropDownDataForLanguage()); studentExt.DropDown.NativeLanguage.SelectedLanguage = (studentExt.NativeLanguageId != null) ? (int)studentExt.NativeLanguageId : -1; studentExt.DropDown.Race = new RaceDropDown(modelService.DropDownDataForRace()); studentExt.DropDown.Race.SelectedRace = (studentExt.RaceId != null) ? (int)studentExt.RaceId : -1; ViewBag.SchoolYear = studentExt.SchoolYear; }