Exemplo n.º 1
0
        public ActionResult Delete(int id)
        {
            Workout workoutToDelete = _workoutRepository.FindWorkout(id);

            if (workoutToDelete != null)
            {
                _workoutRepository.DeleteWorkout(workoutToDelete);
                return(RedirectToAction("Index"));
            }

            return(HttpNotFound("Wrong id"));
        }
Exemplo n.º 2
0
        public IActionResult DeleteConfirmed(int id)
        {
            try
            {
                var exercise = _workoutRepository.DeleteWorkout(id);
            }
            catch (DbUpdateException /* ex */)
            {
                //Log the error (uncomment ex variable name and write a log.
                ModelState.AddModelError("", "Delete failed. Try again, and if the problem persists " +
                                         "see your system administrator.");
            }

            return(RedirectToAction("Index"));
        }
 public void DeleteWorkout(Workout workout, IWorkoutRepository workoutRepository)
 {
     workoutRepository.DeleteWorkout(workout);
 }