示例#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();
        }
示例#2
0
        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));
        }