コード例 #1
0
        public ActionResult DeleteConfirmed(int id)
        {
            Teacher teacher = service.GetTeacherById(id);

            service.DeleteTeacherById(teacher.TeacherID);
            return(RedirectToAction("Index"));
        }
コード例 #2
0
        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"));
        }
コード例 #3
0
 public void DeleteTeacherById(int id)
 {
     teacherService = new TeacherService();
     teacherService.DeleteTeacherById(id);
 }