private ProductPriceRenderingViewModel GetProductPriceRenderingViewModel(Product currentProduct,
                                                                                 Category currentCategory, ProductCatalog currentCatalog)
        {
            var currencyIsoCode = _catalogContext.CurrentPriceGroup.CurrencyISOCode;
            var priceGroupName  = _catalogContext.CurrentPriceGroup.Name;

            ProductPriceRenderingViewModel productPriceRenderingViewModelModel = new ProductPriceRenderingViewModel
            {
                CalculatePriceUrl        = Url.Action("CalculatePrice", "ProductPrice"),
                CalculateVariantPriceUrl = Url.Action("CalculatePriceForVariant", "ProductPrice"),
                CatalogGuid = currentCatalog.Guid,
                Sku         = currentProduct.Sku,
                ProductGuid = currentProduct.Guid
            };

            if (currentProduct.PricesInclTax.TryGetValue(priceGroupName, out var price))
            {
                productPriceRenderingViewModelModel.Price = new Money(price, currencyIsoCode).ToString();
            }

            if (currentProduct.Taxes.TryGetValue(priceGroupName, out var tax))
            {
                productPriceRenderingViewModelModel.Tax = new Money(tax, currencyIsoCode).ToString();
            }

            if (currentCategory != null)
            {
                productPriceRenderingViewModelModel.CategoryGuid = currentCategory.Guid;
            }

            return(productPriceRenderingViewModelModel);
        }
        private ProductPriceRenderingViewModel GetProductPriceRenderingViewModel(Product currentProduct, Category currentCategory, ProductCatalog currentCatalog)
        {
            ProductPriceRenderingViewModel productPriceRenderingViewModelModel = new ProductPriceRenderingViewModel()
            {
                CalculatePriceUrl        = Url.Action("CalculatePrice", "ProductPrice"),
                CalculateVariantPriceUrl = Url.Action("CalculatePriceForVariant", "ProductPrice"),
                CatalogGuid = currentCatalog.Id,
                Sku         = currentProduct.Sku,
                ProductId   = currentProduct.Id
            };

            if (currentCategory != null)
            {
                productPriceRenderingViewModelModel.CategoryGuid = currentCategory.Guid;
            }

            return(productPriceRenderingViewModelModel);
        }
示例#3
0
        public ActionResult Rendering()
        {
            var currentProduct  = _catalogContext.CurrentProduct;
            var currentCategory = _catalogContext.CurrentCategory;
            var currentCatalog  = _catalogContext.CurrentCatalog;

            ProductPriceRenderingViewModel productPriceRenderingViewModelModel = new ProductPriceRenderingViewModel()
            {
                CalculatePriceUrl        = Url.Action("CalculatePrice"),
                CalculateVariantPriceUrl = Url.Action("CalculatePriceForVariant"),
                CatalogGuid = currentCatalog.Id,
                Sku         = currentProduct.Sku,
                ProductId   = currentProduct.Id
            };

            if (currentCategory != null)
            {
                productPriceRenderingViewModelModel.CategoryGuid = currentCategory.Guid;
            }

            return(View(productPriceRenderingViewModelModel));
        }