public IHttpActionResult DeleteExercise(int id)
        {
            if (id <= 0)
            {
                return(ResponseMessage(CreateCustomResponseMessage(HttpStatusCode.BadRequest)));
            }
            var result = _exerciseService.DeleteExercise(id);

            return(ResponseMessage(CreateCustomResponseMessage(result)));
        }
        public ActionResult DeletePost(int id)
        {
            var userId  = Guid.Parse(User.Identity.GetUserId());
            var service = new ExerciseService(userId);

            service.DeleteExercise(id);

            TempData["SaveResult"] = "Your exercise was deleted";

            return(RedirectToAction("Index"));
        }
        public void Should_RepoDeleteExercise_BeCalled_WhenServiceDeleteCalled()
        {
            var exerciseRepo     = new Mock <IExerciseRepository>();
            var exerciseTypeRepo = new Mock <IExerciseTypeRepository>();
            var mapper           = new Mock <IMapper>();

            var objectUnderTest = new ExerciseService(exerciseRepo.Object, exerciseTypeRepo.Object, mapper.Object);

            var id = 1;

            objectUnderTest.DeleteExercise(id);

            exerciseRepo.Verify(r => r.DeleteExercise(id), Times.Once);
        }
Exemple #4
0
        public async Task <IActionResult> DeleteExercise(string exericseId)
        {
            var currentUser = await _userManager.GetUserAsync(User);

            var exercise = await _exerciseService.GetExercise(exericseId);

            if (exercise.UserId == currentUser.Id)
            {
                await _exerciseService.DeleteExercise(exercise);

                return(RedirectToAction("Exercises"));
            }

            return(Challenge());
        }