GET requests can be used on OrdersController with an order ID so that order details can be consumed by third party sites for display. For example, many courier companies expose their APIs, which is used by other sites to display order, shipment, and tracking information.
As an example, let's check out our GET method OrdersController, which takes the ID as a parameter:
// GET: api/Orders/5
[HttpGet("{id}")]
public async Task<IActionResult> GetOrders([FromRoute] Guid id)
{
if (!ModelState.IsValid)
{
return BadRequest(ModelState);
}
var orders = await _context.Orders.Include
(o => o.OrdersProducts).SingleOrDefaultAsync(m => m.Id == id);
if (orders == null)
{
return NotFound();
}
return Ok(orders);
}
Notice that the Include clause is used to include results from the OrdersProducts table. Let's now perform a quick...