public ActionResult <ExerciseEvaluation> GetEvaluation(int trainingId, int exerciseId) { var training = _trainings.GetbyId(trainingId); var exercise = _exercises.GetbyId(exerciseId); if (training == null) { return(NotFound("Geen training met dit id gevonden")); } if (exercise == null) { return(NotFound("Geen oefening met dit id gevonden")); } try { var evaluations = _evaluations.GetEvaluationFromExerciseInTraining(trainingId, exerciseId); if (evaluations == null) { return(Ok()); //Teruggave van een lege lijst } return(Ok(evaluations)); } catch (Exception e) { return(StatusCode(StatusCodes.Status500InternalServerError, e.Message)); } }
public ActionResult <Training> GetTraining(int trainingId) { Training t = _trainings.GetbyId(trainingId); if (t == null) { return(NotFound()); } try { return(Ok(_trainings.GetbyId(trainingId))); } catch (Exception e) { return(StatusCode(StatusCodes.Status500InternalServerError, e.Message)); } }
public ActionResult <IEnumerable <Exercise> > GetExercisesInTraining(int trainingId) { Training t = _trainingen.GetbyId(trainingId); if (t == null) { return(NotFound("Geen training met dit Id")); } try { var exercises = t.TrainingExercises.ToList().Select(te => te.Exercise); return(Ok(exercises)); } catch (Exception e) { return(StatusCode(StatusCodes.Status500InternalServerError, e.Message)); } }