public void Remove(Guid id) { Exercise exercise = exerciseRepository.Get(id); if (exercise == null) { throw new ArgumentException("Invalid guid"); } exerciseRepository.Remove(exercise); exerciseRepository.Save(); }
public async Task <ActionResult <ExerciseResource> > GetExercise(int id) { var exercise = await repository.Get(id); if (exercise == null) { return(NotFound()); } if (exercise.UserId != GetUserId()) { return(Forbid()); } var exerciseResource = mapper.Map <Exercise, ExerciseResource> (exercise); return(Ok(exerciseResource)); }