Beispiel #1
0
        public IActionResult GetById(int id)
        {
            var workout = _workoutService.GetById(id);
            var model   = _mapper.Map <UpdateModel>(workout);

            return(Ok(model));
        }
Beispiel #2
0
 public ActionResult <Workout> Get(int id)
 {
     try
     {
         var workout = _workoutService.GetById(id);
         if (workout == null)
         {
             return(NotFound(id));
         }
         else
         {
             workout.Exercises = workout.Exercises?.OrderBy(x => x.Sequence).ToList();
             return(Ok(workout));
         }
     }
     catch (Exception ex)
     {
         return(StatusCode(500, ex.Message));
     }
 }
        public async Task <ActionResult <WorkoutOutputModel> > Get(int id)
        {
            var result = await workoutService.GetById(id);

            if (result == null)
            {
                return(BadRequest());
            }

            return(result);
        }
        private WorkoutPlan CreatePlanForNewWorkout(int workoutId, int userId)
        {
            Workout workout      = _workoutService.GetById(workoutId);
            var     userSettings = GetUserSettings(userId);

            var plan = new WorkoutPlan(workout, false);

            if (userSettings != null && userSettings.RecommendationsEnabled)
            {
                foreach (var exercisePlan in plan.Exercises)
                {
                    var exercise       = workout.Exercises.First(x => x.ExerciseId == exercisePlan.ExerciseId);
                    var recommendation = _recommendationService.GetRecommendation(exercise.Exercise, null, userSettings);
                    exercisePlan.ApplyRecommendation(recommendation);
                }
            }

            return(plan);
        }
        public async Task <IActionResult> GetById(int id)
        {
            var workout = await _workoutService.GetById(id);

            return(Ok(workout));
        }