示例#1
0
 [HttpGet("{catId}")] //NOTE this route is 'api/cats/:id'
 public ActionResult <Cat> Get(string catId)
 {
     try
     {
         return(Ok(_cs.GetById(catId)));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
示例#2
0
 public ActionResult <Cat> GetById(string id)
 {
     try
     {
         Cat cat = _catService.GetById(id);
         return(Ok(cat));
     }
     catch (Exception err)
     {
         return(BadRequest(err.Message));
     }
 }