Skip to content

Instantly share code, notes, and snippets.

@dcomartin
Created October 26, 2023 19:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dcomartin/69032915466eab900bd58aa7824772d2 to your computer and use it in GitHub Desktop.
Save dcomartin/69032915466eab900bd58aa7824772d2 to your computer and use it in GitHub Desktop.
public class OrderController : Controller
{
private readonly IMediator _mediator;
public OrderController(IMediator mediator)
{
_mediator = mediator;
}
public async Task<IActionResult> Detail(int orderId)
{
try
{
var viewModel = await _mediator.Send(new GetOrderQuery(orderId));
return View(viewModel);
}
catch (OrderNotFoundException ex)
{
return NotFound($"Order ({ex.OrderId}) not found.");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment