public ActionResult <Exercise> AddExerciseToTraining(int trainingId, int exerciseId) { var training = _trainingen.GetbyId(trainingId); var exercise = _exercises.GetbyId(exerciseId); if (training == null) { return(NotFound()); } if (exercise == null) { return(NotFound()); } try { training.AddExerciseToTraining(exercise); _trainingen.SaveChanges(); return(Ok(exercise)); } catch (Exception e) { return(StatusCode(StatusCodes.Status500InternalServerError, e.Message)); } }
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)); } }