Skip to content

Instantly share code, notes, and snippets.

@harry-gordon
Last active February 12, 2024 10:31
Show Gist options
  • Save harry-gordon/30c10f5cafb199f1560eacd974d92f6e to your computer and use it in GitHub Desktop.
Save harry-gordon/30c10f5cafb199f1560eacd974d92f6e to your computer and use it in GitHub Desktop.
public class MyOrderController : RenderController
{
...
public override IActionResult Index()
{
...
if (orderId is not null)
{
// Since there's an order ID present we load it to
// send the details to the view
// (what's the worst that could happen)
var orderPage = (MyOrder) CurrentPage;
orderPage.Order = _ordersService.GetOrder(member);
}
// If we can't find the order we just don't set it
// and the template will handle the null and say
// Sorry, we couldn't find your order :(
return CurrentTemplate(CurrentPage);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment