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 async Task <ActionResult> Delete(int?id)
        {
            if (!id.HasValue)
            {
                return(HttpNotFound());
            }

            try
            {
                var statusCode = await _courseRepository.DeleteCourse(id.Value);

                if (statusCode == HttpStatusCode.NotFound)
                {
                    return(HttpNotFound());
                }

                return(new HttpStatusCodeResult(HttpStatusCode.OK));
            }
            catch (BadRequestException bre)
            {
                var errorString = GetErrorsFromAdycHttpExceptionToString(bre);

                return(new HttpStatusCodeResult(bre.StatusCode, errorString));
            }
        }
Esempio n. 3
0
        private void BtnMainDelete_Click(object sender, RoutedEventArgs e)
        {
            if (MessageBox.Show("Удалить данную запись?", "Удаление записи", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
            {
                courseRepository.DeleteCourse(Id, UserId);

                if (!String.IsNullOrEmpty(FilePath))
                {
                    courseRepository.DeleteFileToDb(UserId, "172.20.2.221", FilePath);
                }

                BtnMainUpdate_Click(null, null);
            }
        }
Esempio n. 4
0
 public string DeleteConfirmed(long id)
 {
     try
     {
         if (objRep.DeleteCourse(id))
         {
             DeleteFiles(this.GetType().Name, id);
             return(Convert.ToString(true));
         }
         return(Convert.ToString(false));
     }
     catch (Exception ex)
     {
         return(ex.Message.ToString());
     }
 }
Esempio n. 5
0
        public async Task <IActionResult> DeleteCourse(int?courseId)
        {
            int result = 0;

            if (courseId == null)
            {
                return(BadRequest());
            }

            try
            {
                result = await course.DeleteCourse(courseId);

                if (result == 0)
                {
                    return(NotFound());
                }
                return(Ok());
            }
            catch (Exception)
            {
                return(BadRequest());
            }
        }
Esempio n. 6
0
 public ActionResult DeleteCourse(int id)
 {
     re.DeleteCourse(id);
     return(RedirectToAction("AllCourses"));
 }
Esempio n. 7
0
 public void Delete(int?Id)
 {
     courseRepository.DeleteCourse(Id);
 }
        public void DeleteCourse(int courseId)
        {
            ICourseRepository repository = new CourseRepository();

            repository.DeleteCourse(courseId);
        }
Esempio n. 9
0
 public Course DeleteCourse(Course course)
 {
     return(courseRepository.DeleteCourse
                (course.Id));
 }
Esempio n. 10
0
 public void Delete(int id)
 {
     Coursecon.DeleteCourse(id);
 }