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("/Modules/SimplCommerce.Module.Orders/Views/Components/OrderSummary.cshtml", model)); }
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.ProductPrice, Quantity = x.Quantity, VariationOptions = CartListItem.GetVariationOption(x.ProductVariation) }).ToList() }; return(View(model)); }
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.ProductPrice, ProductImage = _mediaService.GetThumbnailUrl(x.Product.ThumbnailImage), Quantity = x.Quantity, VariationOptions = CartListItem.GetVariationOption(x.ProductVariation) }).ToList() }; return(Json(model)); }