/// <summary> /// Initializes a new instance of the <see cref="CartLineBaseJsonResult"/> class. /// </summary> /// <param name="line">The line.</param> public CartLineBaseJsonResult(CustomCommerceCartLine line) { this.DiscountOfferNames = new List <string>(); var product = (CommerceCartProduct)line.Product; var productItem = ProductItemResolver.ResolveCatalogItem(product.ProductId, product.ProductCatalog, true); if (line.Images.Count > 0) { this.Image = line.Images[0].GetImageUrl(100, 100); } var userCurrency = StorefrontManager.GetCustomerCurrency(); this.DisplayName = product.DisplayName; this.Color = product.Properties["Color"] as string; this.LineDiscount = ((CommerceTotal)line.Total).LineItemDiscountAmount.ToCurrency(this.GetCurrencyCode(userCurrency, ((CommerceTotal)line.Total).CurrencyCode)); this.Quantity = line.Quantity.ToString(Context.Language.CultureInfo); this.LinePrice = product.Price.Amount.ToCurrency(this.GetCurrencyCode(userCurrency, product.Price.CurrencyCode)); this.LineTotal = line.Total.Amount.ToCurrency(this.GetCurrencyCode(userCurrency, line.Total.CurrencyCode)); this.ExternalCartLineId = StringUtility.RemoveCurlyBrackets(line.ExternalCartLineId); this.ProductUrl = product.ProductId.Equals(StorefrontManager.CurrentStorefront.GiftCardProductId, StringComparison.OrdinalIgnoreCase) ? StorefrontManager.StorefrontUri("/buygiftcard") : LinkManager.GetDynamicUrl(productItem); }
/// <summary> /// Initializes a new instance of the <see cref="ProductItemResolverTest"/> class. /// </summary> public ProductItemResolverTest() { this.productService = Substitute.For <IProductService>(); this.productHelper = Substitute.For <ProductHelper>(); RouteConfig.RegisterRoutes(); this.processor = new ProductItemResolver { ProductService = this.productService, ProductHelper = this.productHelper }; }
public void ShouldReadProductServiceAndProductHelperFromWindsorContainer() { // Arrange var container = Substitute.For <IWindsorContainer>(); container.Resolve <IProductService>().Returns(this.productService); container.Resolve <ProductHelper>().Returns(this.productHelper); // Act this.processor = new ProductItemResolver { WindsorContainer = container }; // Assert this.processor.ProductService.Should().Be(this.productService); this.processor.ProductHelper.Should().Be(this.productHelper); }
public Item ResolveCatalogItem(string itemId, string catalogName, bool isProduct) { return(ProductItemResolver.ResolveCatalogItem(itemId, catalogName, isProduct)); }