public ActionResult DeleteConfirmed(int id) { Teacher teacher = service.GetTeacherById(id); service.DeleteTeacherById(teacher.TeacherID); return(RedirectToAction("Index")); }
public ActionResult DeleteConfirmed(int?id) { if (id == 0 || !id.HasValue) { return(RedirectToAction("Index")); } teacherService = new TeacherService(); subjectService = new SubjectService(); staffService = new StaffService(); // pass subjects to singleton List <Subject> subjects = subjectService.getSubjectsByTeacherId((int)id); hireTeacherSingleton.Subjects = subjects; // remove teacher from staff staffService.DeleteTeacherFromStaffById((int)id); //delete the teacher teacherService.DeleteTeacherById((int)id); // if teacher had a subject allocated substitue him, if not don't if (subjects.Count == 0) { return(RedirectToAction("Index")); } return(RedirectToAction("HireNewTeacher")); }
public void DeleteTeacherById(int id) { teacherService = new TeacherService(); teacherService.DeleteTeacherById(id); }