Example #1
0
        private static IActionResult DoPut(HttpRequest req)
        {
            string      json    = new StreamReader(req.Body).ReadToEnd();
            BookChapter chapter = JsonConvert.DeserializeObject <BookChapter>(json);

            s_bookChaptersService.Update(chapter);
            return(new OkResult());
        }
 public IActionResult PutBookChapter(Guid id, [FromBody] BookChapter chapter)
 {
     if (chapter == null || id != chapter.Id)
     {
         return(BadRequest());
     }
     if (_bookChaptersService.Find(id) == null)
     {
         return(NotFound());
     }
     _bookChaptersService.Update(chapter);
     return(new NoContentResult());
 }
 public IActionResult PutBookChapter(Guid id, [FromBody] BookChapter chapter)
 {
     // 如果参数BookChapter或者id为空,则返回BadRequest(HTTP错误400)
     if (chapter == null || id != chapter.Id)
     {
         return(BadRequest());
     }
     // 如果对象尚未在集合中,则返回NotFound。
     if (_bookChaptersService.Find(id) == null)
     {
         return(NotFound());
     }
     // 如果找到该对象,则更新该对象,并且返回成功结果204 - 空主体的内容(NoContentResult)
     _bookChaptersService.Update(chapter);
     return(new NoContentResult());
 }