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 <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); }