Skip to content

Instantly share code, notes, and snippets.

@dcomartin dcomartin/cart2.cs
Created Feb 22, 2018

Embed
What would you like to do?
[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
You can’t perform that action at this time.