コード例 #1
0
        public IActionResult Get(Guid id)
        {
            var exercise = exercises.Get(id);

            if (exercise == null)
            {
                return(NotFound());
            }
            return(Ok(ExerciseModel.ToModel(exercise)));
        }
コード例 #2
0
        public IActionResult PostExercise(Guid id, [FromBody] ExerciseModel exercise)
        {
            var newExercise = homeworks.AddExercise(id, ExerciseModel.ToEntity(exercise));

            if (newExercise == null)
            {
                return(BadRequest());
            }
            return(CreatedAtRoute("GetExercise", new { id = newExercise.Id }, ExerciseModel.ToModel(newExercise)));
        }
コード例 #3
0
 public IActionResult Get()
 {
     return(Ok(ExerciseModel.ToModel(exercises.GetAll())));
 }