public ActionResult ManageStaffEducationsModal(int id) { StaffDashboardViewModel sdVM = new StaffDashboardViewModel(); sdVM.SelectedStaffData.Staff = db.Staffs.Find(id); int i = 0; //get user's educations List <Education> selectedStaffEducations = db.Educations.Include(x => x.Staff).Where(x => x.Staff_ID == sdVM.SelectedStaffData.Staff.ID).ToList(); //Map user's educations to view model: ManageEducationsDataList foreach (var education in selectedStaffEducations) { ManageStaffEducationsViewModel manageEducationsVM = new ManageStaffEducationsViewModel(); manageEducationsVM.StaffID = education.Staff_ID; manageEducationsVM.School = education.School; manageEducationsVM.DegreeID = education.Degree_ID; manageEducationsVM.CompletedDate = education.Completed_Date; manageEducationsVM.HasEducation = true; manageEducationsVM.RemoveEducation = false; manageEducationsVM.StaffName = education.Staff.Staff_Name; manageEducationsVM.EducationID = education.ID; manageEducationsVM.CurrentListIndex = i; manageEducationsVM.IsNewSkill = false; i++; sdVM.ManageEducationsDataList.Add(manageEducationsVM); } ViewBag.DegSelectList = new SelectList(db.Adm_Degrees, "ID", "Degree"); ViewBag.ListDegrees = db.Adm_Degrees; return(PartialView("_staffEducationsModal", sdVM)); }
public ActionResult addSingleEducation() { ViewBag.ListDegrees = db.Adm_Degrees; ViewBag.DegSelectList = new SelectList(db.Adm_Degrees, "ID", "Degree"); ManageStaffEducationsViewModel newSEVM = new ManageStaffEducationsViewModel(); newSEVM.IsNewSkill = true; return(PartialView("_singleStaffEducation", newSEVM)); }