Esempio n. 1
0
 public IActionResult GetOne(int id)
 {
     using (var db = new AppDb())
     {
         db.Connection.Open();
         var query  = new BlogPostQuery(db);
         var result = query.FindOne(id);
         if (result == null)
         {
             return(new NotFoundResult());
         }
         return(new OkObjectResult(result));
     }
 }
Esempio n. 2
0
 public IActionResult PutOne(int id, [FromBody] BlogPost body)
 {
     using (var db = new AppDb())
     {
         db.Connection.Open();
         var query  = new BlogPostQuery(db);
         var result = query.FindOne(id);
         if (result == null)
         {
             return(new NotFoundResult());
         }
         result.Title   = body.Title;
         result.Content = body.Content;
         result.Update();
         return(new OkObjectResult(result));
     }
 }