Exemple #1
0
        public async Task <ActionResult <WorkoutDetailDto> > Get(int id)
        {
            if (string.IsNullOrEmpty(CurrentUserId))
            {
                return(Unauthorized(new { message = $"Unable to fetch workout with id {id}, no user is currently logged in." }));
            }

            return(Ok(await _workoutRepository.Get(CurrentUserId, id)));
        }
Exemple #2
0
        public async Task <ActionResult <WorkoutResource> > GetWorkout(int id)
        {
            var workout = await repository.Get(id);

            if (workout == null)
            {
                return(NotFound());
            }

            if (workout.UserId != GetUserId())
            {
                return(Forbid());
            }

            return(mapper.Map <Workout, WorkoutResource> (workout));
        }
        public async Task <IEnumerable <Workout> > Get([FromQuery(Name = "")] PageableUserIdRequest request)
        {
            var workouts = await repository.Get(request);

            return(workouts);
        }