public ActionResult Delete(int id) { TeacherDataController controller = new TeacherDataController(); controller.DeleteTeacher(id); return(RedirectToAction("list")); }
/// <summary> /// Routes Teacher Update Page. Displays information from the database. /// </summary> /// <param>Id of the teacher</param> /// <returns>an update teacher webpage which displays current information and asks for new information</returns> /// <example>GET : /Teacher/Update/5</example> public ActionResult Update(int id) { //new data controller initiated TeacherDataController controller = new TeacherDataController(); //returns teacher information from FindTeacher method Teacher SelectedTeacher = controller.FindTeacher(id); return(View(SelectedTeacher)); }
// GET : /Teacher/DeleteConfirm/{id} public ActionResult DeleteConfirm(int id) { //instantiating a new controller TeacherDataController controller = new TeacherDataController(); //creating newteacher object with the findteacher function Teacher NewTeacher = controller.FindTeacher(id); //return newteacher object to show view return(View(NewTeacher)); }
// GET: Teacher/List public ActionResult List(string SearchKey = null) { //instantiating a new controller TeacherDataController controller = new TeacherDataController(); // creating a new list of Teachers using listteachers function IEnumerable <Teacher> Teachers = controller.ListTeachers(SearchKey); //return Teachers list to list view return(View(Teachers)); }
public ActionResult Update(int id, string teacherfname, string teacherlname, DateTime hiredate) { //new teacher object Teacher TeacherInfo = new Teacher(); TeacherInfo.teacherfname = teacherfname; TeacherInfo.teacherlname = teacherlname; TeacherInfo.hiredate = hiredate; //calls the teacher data controller TeacherDataController controller = new TeacherDataController(); controller.UpdateTeacher(id, TeacherInfo); //returns to the particular teacher info page return(RedirectToAction("Show/" + id)); }
public ActionResult Create(string teacherfname, string teacherlname, DateTime hiredate) { Debug.WriteLine("I have create"); Debug.WriteLine(teacherfname); Debug.WriteLine(teacherlname); Debug.WriteLine(hiredate); //create new teacher object Teacher NewTeacher = new Teacher(); NewTeacher.teacherfname = teacherfname; NewTeacher.teacherlname = teacherlname; NewTeacher.hiredate = hiredate; //send new object to datacontroller to execute sql query and add teacher to database TeacherDataController controller = new TeacherDataController(); controller.CreateTeacher(NewTeacher); return(RedirectToAction("List")); }