Beispiel #1
0
        public ActionResult Delete(int id, IFormCollection collection)
        {
            try
            {
                // TODO: Add delete logic here
                courseDataProvider.Delete(id);

                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                return(View());
            }
        }
Beispiel #2
0
        /// <summary>
        /// Deletes the specified <see cref="Course" />.
        /// </summary>
        /// <param name="course">The course.</param>
        /// <returns>
        /// Total number of records affected. This may aggregate counts from <see cref="Chapter" /> and <see cref="Slide" /> members.
        /// </returns>
        /// <exception cref="Neddle.NeddleException">
        /// </exception>
        public int DeleteCourse(Course course)
        {
            // TODO: KLC add option here to allow preservation of slides, e.g. for reuse in other courses

            Contract.Requires <ArgumentNullException>(course != null);

            Logger.DebugFormat(Resources.Courses.CourseDelete, course.Id);
            course.Validate();
            Exists(course, true);

            int affected = _dataProvider.Delete(course);

            if (affected == 0)
            {
                throw new NeddleException(Resources.Courses.CourseCouldNotBeDeleted, course.Id);
            }

            return(affected);
        }