public async Task <ActionResult> Index(string shoppingCartId = null)
        {
            ShoppingCart cart = await _shoppingCartPersistence.Retrieve(shoppingCartId);

            IDictionary <string, ProductPart> products =
                await _productService.GetProductDictionary(cart.Items.Select(line => line.ProductSku));

            var items = await _priceService.AddPrices(cart.Items);

            ShoppingCartLineViewModel[] lines = await Task.WhenAll(items.Select(async item =>
            {
                ProductPart product          = products[item.ProductSku];
                Amount price                 = _priceStrategy.SelectPrice(item.Prices);
                ContentItemMetadata metaData = await _contentManager.GetContentItemMetadataAsync(product);
                return(new ShoppingCartLineViewModel
                {
                    Quantity = item.Quantity,
                    ProductSku = item.ProductSku,
                    ProductName = product.ContentItem.DisplayText,
                    UnitPrice = price,
                    LinePrice = item.Quantity *price,
                    ProductUrl = Url.RouteUrl(metaData.DisplayRouteValues),
                    Attributes = item.Attributes.ToDictionary(attr => attr.AttributeName)
                });
            }));

            var model = new ShoppingCartViewModel
            {
                Id     = shoppingCartId,
                Lines  = lines,
                Totals = lines.GroupBy(l => l.LinePrice.Currency).Select(g => new Amount(g.Sum(l => l.LinePrice.Value), g.Key))
            };

            return(View(model));
        }
        public async Task AddExistingItemToCart()
        {
            await _cartStorage.Store(new List <ShoppingCartItem> {
                new ShoppingCartItem(3, "foo")
            });

            await _controller.AddItem(new ShoppingCartLineUpdateModel { Quantity = 7, ProductSku = "foo" });

            var cart = await _cartStorage.Retrieve();

            Assert.Equal(new List <ShoppingCartItem> {
                new ShoppingCartItem(10, "foo")
            }, cart);
        }