コード例 #1
0
 public IActionResult Put(Guid id, [FromBody] HomeworkModel model)
 {
     try {
         var homework = homeworks.Update(id, HomeworkModel.ToEntity(model));
         return(CreatedAtRoute("Get", new { id = homework.Id }, HomeworkModel.ToModel(homework)));
     } catch (ArgumentException e) {
         return(BadRequest(e.Message));
     }
 }
コード例 #2
0
        public IActionResult Get(Guid id)
        {
            var homework = homeworks.Get(id);

            if (homework == null)
            {
                return(NotFound());
            }
            return(Ok(HomeworkModel.ToModel(homework)));
        }
コード例 #3
0
 public IActionResult Get()
 {
     return(Ok(HomeworkModel.ToModel(homeworks.GetAll())));
 }