Beispiel #1
0
        public IActionResult DeleteCourse(string id, int courseId)
        {
            ViewData["Id"] = id;

            //deleting all presentations
            Course course = repository.Courses
                            .FirstOrDefault(c => c.CourseId == courseId);

            while (course.Presentations.Count() > 0)
            {
                Presentation p        = course.Presentations.FirstOrDefault();
                Presentation deletedP = repository.DeletePresentation(p.PresentationId);
            }

            Course deletedCourse = repository.DeleteCourse(courseId);

            if (deletedCourse != null)
            {
                TempData["messageIn"] = $"Course: '{deletedCourse.Title}' has been deleted!";
            }
            return(RedirectToAction("Index", new{ id, status = "Private",
                                                  sort = "Title", order = "asc" }));
        }