public ActionResult<Knight> Get() { try { return Ok(_service.GetAll()); } catch (Exception e) { return BadRequest(e.Message); } }
public ActionResult <IEnumerable <Knight> > GetAll() { try { return(Ok(_service.GetAll())); } catch (System.Exception err) { return(BadRequest(err.Message)); } }
public ActionResult <IEnumerable <Knight> > GetAll() { try { IEnumerable <Knight> knights = _service.GetAll(); return(Ok(knights)); } catch (Exception e) { return(BadRequest(e.Message)); } }
// 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)); } }