public async Task<IViewComponentResult> InvokeAsync()
        {
            var curentUser = await _workContext.GetCurrentUser();

            var cartItems = _cartService.GetCartItems(curentUser.Id);
            var model = new CartViewModel
            {
                CartItems = cartItems.Select(x => new CartListItem
                {
                    Id = x.Id,
                    ProductName = x.Product.Name,
                    ProductPrice = x.Product.Price,
                    Quantity = x.Quantity,
                    VariationOptions = CartListItem.GetVariationOption(x.Product)
                }).ToList()
            };

            return View(model);
        }
Beispiel #2
0
        public async Task<IActionResult> List()
        {
            var currentUser = await _workContext.GetCurrentUser();
            var cartItems = _cartService.GetCartItems(currentUser.Id);

            var model = new CartViewModel
            {
                CartItems = cartItems.Select(x => new CartListItem
                {
                    Id = x.Id,
                    ProductName = x.Product.Name,
                    ProductPrice = x.Product.Price,
                    ProductImage = _mediaService.GetThumbnailUrl(x.Product.ThumbnailImage),
                    Quantity = x.Quantity,
                    VariationOptions = CartListItem.GetVariationOption(x.Product)
                }).ToList()
            };

            return Json(model);
        }