コード例 #1
0
 public ActionResult<Knight> Get()
 {
     try
      {
     return Ok(_service.GetAll());
      }
      catch (Exception e)
      {
     return BadRequest(e.Message);
      }
 }
コード例 #2
0
 public ActionResult <IEnumerable <Knight> > GetAll()
 {
     try
     {
         return(Ok(_service.GetAll()));
     }
     catch (System.Exception err)
     {
         return(BadRequest(err.Message));
     }
 }
コード例 #3
0
 public ActionResult <IEnumerable <Knight> > GetAll()
 {
     try
     {
         IEnumerable <Knight> knights = _service.GetAll();
         return(Ok(knights));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
コード例 #4
0
 // This attribute defines that the method to follow is a "get" request
 public ActionResult <IEnumerable <Knight> > getAll()
 // IEnumerable takes the place of any collection type (List, Array, etc...)
 // ActionResult <-- "of type" List <-- "of type" Knight
 {
     try
     {
         IEnumerable <Knight> knights = _service.GetAll();
         return(Ok(knights));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }