public ActionResult Create(string TeacherFname, string TeacherLname, string EmployeeNumber, decimal Salary) { //Identify that thismethod is running //Identify the inputs provided from the form Debug.WriteLine("I have access to create a method!"); Debug.WriteLine(TeacherFname); Debug.WriteLine(TeacherLname); Debug.WriteLine(EmployeeNumber); Debug.WriteLine(Salary); //Server side validation for preventing form to submit with empty fields. if (TeacherFname == "" || EmployeeNumber == "") { return(RedirectToAction("New")); } Teacher NewTeacher = new Teacher(); NewTeacher.Teacherfname = TeacherFname; NewTeacher.Teacherlname = TeacherLname; NewTeacher.Employeenumber = EmployeeNumber; NewTeacher.Salary = Salary; TeacherDataController controller = new TeacherDataController(); controller.AddTeacher(NewTeacher); return(RedirectToAction("List")); }
// GET: /Teacher/Delete/{id} public ActionResult Delete(int id) { TeacherDataController controller = new TeacherDataController(); controller.DeleteTeacher(id); return(RedirectToAction("List")); }
//Get:/Teacher/DeleteConfirm/{id} public ActionResult DeleteConfirm(int id) { TeacherDataController controller = new TeacherDataController(); Teacher NewTeacher = controller.FindTeacher(id); return(View(NewTeacher)); }
public ActionResult Update(int id) { TeacherDataController controller = new TeacherDataController(); Teacher SelectedTeacher = controller.FindTeacher(id); return(View(SelectedTeacher)); }
//Get:/Teacher/List //Acquire information about the teachers and send it to the List.cshtml public ActionResult List(string SearchKey = null) { //We will get the information from ListTeachers method TeacherDataController controller = new TeacherDataController(); IEnumerable <Teacher> TeacherDetail = controller.ListTeachers(SearchKey); return(View(TeacherDetail)); }
public ActionResult Update(int id, string Teacherfname, string Teacherlname, decimal Salary, string Employeenumber) { if (Convert.ToString(Salary) == null) { return(RedirectToAction("Show/" + id)); } Teacher TeacherInfo = new Teacher(); TeacherInfo.Teacherfname = Teacherfname; TeacherInfo.Teacherlname = Teacherlname; TeacherInfo.Employeenumber = Employeenumber; TeacherInfo.Salary = Salary; TeacherDataController controller = new TeacherDataController(); controller.UpdateTeacher(id, TeacherInfo); return(RedirectToAction("Show/" + id)); }