public ActionResult UpdateTeacherChanges(string teacherFName, string teacherLName, string empNumber, string salary, string teacherid = null, string hireDate = null) { Teacher newTeacher = new Teacher { teacherFname = teacherFName, teacherLname = teacherLName, employeeNumber = empNumber, salary = salary, hireDate = DateTime.Parse(hireDate), teacherId = Convert.ToInt32(teacherid) }; TeacherDataController controller = new TeacherDataController(); controller.UpdateTeacher(newTeacher); return(RedirectToAction("Show/" + teacherid)); }
public ActionResult Update([Bind(Include = "EmployeeNumber,HireDate,Salary,TeacherFname,TeacherLname")] Teacher teacherInfo, int TeacherId) { // validate the data (server-side) if (ModelState.IsValid) { TeacherDataController controller = new TeacherDataController(); // Update teacher teacherInfo.TeacherId = TeacherId; controller.UpdateTeacher(teacherInfo); // Redirect to updated teacher profile return(RedirectToAction($"Show/{TeacherId}")); } else { // on validation fail:- show last saved teacher information return(RedirectToAction($"Update/{TeacherId}")); } }