Ejemplo n.º 1
0
        public void Remove(Guid id)
        {
            Exercise exercise = exerciseRepository.Get(id);

            if (exercise == null)
            {
                throw new ArgumentException("Invalid guid");
            }
            exerciseRepository.Remove(exercise);
            exerciseRepository.Save();
        }
Ejemplo n.º 2
0
        public async Task <ActionResult <Exercise> > DeleteExercise(int id)
        {
            var exercise = await repository.Get(id);

            if (exercise == null)
            {
                return(NotFound());
            }
            if (exercise.UserId != GetUserId())
            {
                return(Forbid());
            }

            repository.Remove(exercise);
            await unitOfWork.CompleteAsync();

            return(exercise);
        }