GET returns Task<ActionResult>
Example: GET: api/TodoItems
GET without parameter returns a list of objects.
Produce a Status 404 if items are not found, by using the
NotFound()method
GET with ID param returns Task<ActionResult
Example: GET: api/TodoItems/5
Mark method with
[HttpGet("{id}")]to constrain route to matchidProduce a Status 404 if item is not found, by using the
NotFound()method
PUT with ID returns No Content as Task
Example: PUT: api/TodoItems/5
Mark Method with
[HttpPut("{id}")]to constrain route to matchidProduce a Status 400 if Attribute doesn’t match parameter, by using the
BadRequest()methodProduce a Status 404 if item is not found, by using the
NotFound()methodProduce a Status 204 if successful, and nothing is returned, by using
NoContent()method
POST with ID return ActionName as Task
Example: POST: api/TodoItems
Mark Method with
[[HttpPost]the HTTP body will be parsed and mapped to parameterProduce a Status 400 Bad Request, on empty or error, by using the
Problem('why message')methodProduce a Status 201, redirecting to where it’s created. e.g. location: http://localhost:23015/api/T/1 using the CreatedAtAction() method
Example:
CreatedAtAction(nameof (GetT), new { id = T.Id }, t);Use `nameof(T) instead of hardcoded string of the GET Method
DELETE with ID returns No Content as Task
Example: DELETE: api/TodoItems/5
Mark Method with
[HttpDelete("{id}")]to constrain route to matchidProduce a Status 404 if item is not found, by using the
NotFound()methodProduce a Status 204 if successful, and nothing is returned, by using
NoContent()method