Skip to content

Instantly share code, notes, and snippets.

@dcomartin
Created February 22, 2018 23:56
Show Gist options
  • Save dcomartin/a6fbaeb34dbb3f2d55517d33ec8198d1 to your computer and use it in GitHub Desktop.
Save dcomartin/a6fbaeb34dbb3f2d55517d33ec8198d1 to your computer and use it in GitHub Desktop.
[HttpGet("/cart")]
public IActionResult CartHtml2()
{
var cart = GetShoppingCart();
var vm = new ShoppingCartViewModel();
vm.Products = cart.Products.Select(x => new ShoppingCartProduct
{
Id = x.ProductId,
Product = x.Name,
Colour = x.Colour,
Size = x.Size,
Price = x.Price,
Links = new List<Link>
{
new Link
{
Rel = "ProductDetail",
Href = _urlHelper.Action("Product", new { Id = x.ProductId })
}
},
Actions = new List<Link>
{
new Link
{
Rel = "ChangeQuantity",
Href = _urlHelper.Action("ChangeQuantity", "Cart", new { Id = x.ProductId })
}
}
});
return View(vm);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment