Esempio n. 1
0
        public ActionResult Delete(Guid id, FormCollection collection)
        {
            try
            {
                // TODO: Add delete logic here

                List <TeacherModel> teachersList = teacherRepository.GetAllTeachersByCourseId(id);
                foreach (TeacherModel teacher in teachersList)
                {
                    List <StudentModel> studentsList = studentRepository.GetAllStudentsByTeacherId(teacher.TeacherId);
                    foreach (StudentModel student in studentsList)
                    {
                        List <InvoiceModel> invoicesList = invoiceRepository.GetAllInvoicesByStudentId(student.StudentId);
                        foreach (InvoiceModel invoice in invoicesList)
                        {
                            invoiceRepository.Delete(invoice.InvoiceId);
                        }

                        studentRepository.Delete(student.StudentId);
                    }

                    teacherRepository.DeleteTeacher(teacher.TeacherId);
                }

                courseRepository.DeleteCourse(id);

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View("Delete"));
            }
        }
Esempio n. 2
0
        public ActionResult Delete(Guid id, FormCollection collection)
        {
            try
            {
                // TODO: Add delete logic here

                List <StudentModel> studentsList = studentRepository.GetAllStudentsByProgramId(id);
                foreach (StudentModel student in studentsList)
                {
                    List <InvoiceModel> invoices = invoiceRepository.GetAllInvoicesByStudentId(student.StudentId);
                    foreach (InvoiceModel invoice in invoices)
                    {
                        invoiceRepository.Delete(invoice.InvoiceId);
                    }

                    studentRepository.Delete(student.StudentId);
                }

                programRepository.Delete(id);

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View("Delete"));
            }
        }