One request, followed end to end

This is the real output of bnl-dotnet endpoint OrdersController.Checkout against the five files in the tabs below. The diagram follows the checkout from the controller through pricing, inventory and payment - loops, a switch, a try/catch, early returns and every call into your own code, spliced into one picture. Scroll to zoom, drag to pan.

Controllers/OrdersController.cs
1using Microsoft.AspNetCore.Mvc;
2using OrdersApi.Models;
3using OrdersApi.Services;
4
5namespace OrdersApi.Controllers;
6
7[ApiController]
8[Route("api/[controller]")]
9public class OrdersController(PricingService pricing, InventoryService inventory, PaymentService payments) : ControllerBase
10{
11 [HttpPost("checkout")]
12 public async Task<IActionResult> Checkout(CheckoutRequest request)
13 {
14 if (request.Lines.Count == 0)
15 {
16 return BadRequest("The basket is empty.");
17 }
18
19 decimal total = pricing.Calculate(request);
20
21 bool reserved = inventory.TryReserve(request.Lines);
22
23 if (!reserved)
24 {
25 return Conflict("One or more items are out of stock.");
26 }
27
28 try
29 {
30 string receipt = await payments.ChargeAsync(request.CustomerId, total);
31 return Ok(new { receipt, total });
32 }
33 catch (PaymentDeclinedException)
34 {
35 inventory.Release(request.Lines);
36 return StatusCode(StatusCodes.Status402PaymentRequired, "The payment was declined.");
37 }
38 }
39}
bnl-dotnet endpoint OrdersController.Checkout
  • call into your code
  • framework / library call
  • decision
  • loop
  • return

Get the full composed view for your own code