コード例 #1
0
        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));
        }
コード例 #2
0
        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));
        }
コード例 #3
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.ProductPrice,
                    ProductImage     = _mediaService.GetThumbnailUrl(x.Product.ThumbnailImage),
                    Quantity         = x.Quantity,
                    VariationOptions = CartListItem.GetVariationOption(x.ProductVariation)
                }).ToList()
            };

            return(Json(model));
        }