protected override void RenderContent(PrintContext printContext, XElement output) { string ListPriceKey = "List"; XElement baseXml = new XElement("base"); base.RenderContent(printContext, baseXml); XElement textFrame = baseXml.Element("TextFrame"); Item dataItem = GetDataItem(printContext); XElement xElement = RenderItemHelper.CreateXElement("TextFrame", base.RenderingItem, printContext.Settings.IsClient, dataItem); this.SetAttributes(xElement); output.Add(xElement); XAttribute xAttribute = output.Attribute("ParagraphStyle"); string text = (xAttribute != null && !string.IsNullOrEmpty(xAttribute.Value)) ? xAttribute.Value : "H1 Orange"; Field fieldname = dataItem.Fields[this.ContentFieldName]; DateField dateField = fieldname; var request = new GetProductPricesRequest(dataItem["ExternalID"]); var response = new PricingServiceProvider(); var price = response.GetProductPrices(request).Prices[ListPriceKey].Amount; //var price = response.Prices.ContainsKey(ListPriceKey) ? response.Prices[ListPriceKey].Amount : decimal.Zero; //var price = this.pricingService.GetProductPrice("11"); IEnumerable<XElement> result = this.FormatText(text, price.ToString("c")); xElement.Add(result); this.RenderChildren(printContext, xElement); }
public PricingManager(IConnectServiceProvider connectServiceProvider, ILogService <CommonLog> logService) : base(logService) { Assert.ArgumentNotNull(connectServiceProvider, nameof(connectServiceProvider)); this.pricingServiceProvider = connectServiceProvider.GetPricingServiceProvider(); }
public PricingManager(PricingServiceProvider pricingServiceProvider, CurrencyManager currencyManager, StorefrontContext storefrontContext) { Assert.ArgumentNotNull(pricingServiceProvider, nameof(pricingServiceProvider)); PricingServiceProvider = pricingServiceProvider; CurrencyManager = currencyManager; StorefrontContext = storefrontContext; }
public string GetExternalPrice(string ExternalID) { string ListPriceKey = "List"; var request = new GetProductPricesRequest(ExternalID); var response = new PricingServiceProvider(); var price = response.GetProductPrices(request).Prices[ListPriceKey].Amount; return(price.ToString("c")); }
public string GetExternalPrice(string ExternalID) { string ListPriceKey = "List"; var request = new GetProductPricesRequest(ExternalID); var response = new PricingServiceProvider(); var price = response.GetProductPrices(request).Prices[ListPriceKey].Amount; return price.ToString("c"); }
public ManagerResponse <GetSupportedCurrenciesResult, IReadOnlyCollection <string> > GetSupportedCurrencies(string catalogName) { if (StorefrontContext.Current == null) { throw new InvalidOperationException("Cannot be called without a valid storefront context."); } var request = new GetSupportedCurrenciesRequest(StorefrontContext.Current.ShopName, catalogName); var result = PricingServiceProvider.GetSupportedCurrencies(request); return(new ManagerResponse <GetSupportedCurrenciesResult, IReadOnlyCollection <string> >(result, result.Currencies)); }
public PricingManagerTests() { var connectServiceProvider = Substitute.For <IConnectServiceProvider>(); this.pricingServiceProvider = Substitute.For <PricingServiceProvider>(); this.logService = Substitute.For <ILogService <CommonLog> >(); connectServiceProvider.GetPricingServiceProvider().Returns(this.pricingServiceProvider); this.fixture = new Fixture(); this.pricingManager = Substitute.For <PricingManager>(connectServiceProvider, this.logService); }
public ManagerResponse <ServiceProviderResult, bool> CurrencyChosenPageEvent(string currency) { Assert.ArgumentNotNullOrEmpty(currency, nameof(currency)); if (StorefrontContext.Current == null) { throw new InvalidOperationException("Cannot be called without a valid storefront context."); } var request = new CurrencyChosenRequest(StorefrontContext.Current.ShopName, currency); var result = PricingServiceProvider.CurrencyChosen(request); return(new ManagerResponse <ServiceProviderResult, bool>(result, result.Success)); }
/// <summary> /// Initializes a new instance of the <see cref="CartService" /> class. /// </summary> /// <param name="cartServiceProvider">The service provider.</param> /// <param name="wishListServiceProvider">The wish list service provider.</param> /// <param name="pricingServiceProvider">The pricing service provider.</param> /// <param name="shopName">Name of the shop.</param> /// <param name="contactFactory">The visitor factory.</param> /// <param name="inventoryServiceProvider">The inventory service provider.</param> /// <param name="customerServiceProvider">The customer service provider.</param> public CartService([NotNull] CartServiceProvider cartServiceProvider, [NotNull] WishListServiceProvider wishListServiceProvider, [NotNull] PricingServiceProvider pricingServiceProvider, [NotNull] string shopName, ContactFactory contactFactory, [NotNull] InventoryServiceProvider inventoryServiceProvider, [NotNull] CustomerServiceProvider customerServiceProvider) { Assert.ArgumentNotNull(cartServiceProvider, "cartServiceProvider"); Assert.ArgumentNotNull(wishListServiceProvider, "wishListServiceProvider"); Assert.ArgumentNotNull(pricingServiceProvider, "pricingServiceProvider"); Assert.ArgumentNotNull(customerServiceProvider, "customerServiceProvider"); Assert.ArgumentNotNullOrEmpty(shopName, "shopName"); this._cartServiceProvider = cartServiceProvider; this._pricingServiceProvider = pricingServiceProvider; this.shopName = shopName; this.contactFactory = contactFactory; this._inventoryServiceProvider = inventoryServiceProvider; this._customerServiceProvider = customerServiceProvider; this._wishListServiceProvider = wishListServiceProvider; }
/// <summary> /// Initializes a new instance of the <see cref="CartsServiceTest"/> class. /// </summary> public CartsServiceTest() { this.cart = new Cart(); this.cartFromAnonymous = new Cart(); this.result = new CartResult { Cart = this.cart }; this.resultFromAnonymous = new CartResult { Cart = this.cartFromAnonymous }; this.cartServiceProvider = Substitute.For <CartServiceProvider>(); this.cartServiceProvider.CreateOrResumeCart(Arg.Is <CreateOrResumeCartRequest>(r => r.UserId == "John Carter")).Returns(this.result); var pricesResult = new GetProductPricesResult(); pricesResult.Prices.Add("List", new Price(0, "USD")); this.pricingService = Substitute.For <PricingServiceProvider>(); this.pricingService.GetProductPrices(Arg.Any <GetProductPricesRequest>()).Returns(pricesResult); this.contactId = Guid.NewGuid(); this.cartServiceProvider.CreateOrResumeCart(Arg.Is <CreateOrResumeCartRequest>(r => r.UserId == ID.Parse(this.contactId).ToString())).Returns(this.resultFromAnonymous); this.cartServiceProvider.GetCarts(Arg.Any <GetCartsRequest>()).Returns(new GetCartsResult { Carts = Enumerable.Empty <CartBase>() }); this.contactFactory = Substitute.For <ContactFactory>(); this.contactFactory.GetContact().Returns("John Carter"); var inventoryResult = new GetStockInformationResult(); inventoryResult.StockInformation.ToList().Add(new StockInformation { Product = new InventoryProduct { ProductId = "1001" }, Status = StockStatus.InStock }); this._inventoryService = Substitute.For <InventoryServiceProvider>(); this._inventoryService.GetStockInformation(Arg.Any <GetStockInformationRequest>()).Returns(inventoryResult); this._customerService = Substitute.For <CustomerServiceProvider>(); this._wishListServiceProvider = Substitute.For <WishListServiceProvider>(); this.service = new CartService(this.cartServiceProvider, this._wishListServiceProvider, this.pricingService, "autohaus", this.contactFactory, this._inventoryService, this._customerService); }
public ManagerResponse <GetProductPricesResult, IDictionary <string, Price> > GetProductPrices(string catalogName, string productId, bool includeVariants, string userId, params string[] priceTypeIds) { if (priceTypeIds == null) { priceTypeIds = _defaultPriceTypeIds; } var request = new GetProductPricesRequest(productId, priceTypeIds) { DateTime = GetCurrentDate() }; request.UserId = userId; request.CurrencyCode = CurrencyManager.CurrencyContext.CurrencyCode; var result = PricingServiceProvider.GetProductPrices(request); result.WriteToSitecoreLog(); return(new ManagerResponse <GetProductPricesResult, IDictionary <string, Price> >(result, result.Prices ?? new Dictionary <string, Price>())); }
public ManagerResponse <GetProductBulkPricesResult, IDictionary <string, Price> > GetProductBulkPrices(string catalogName, IEnumerable <string> productIds, params string[] priceTypeIds) { Assert.ArgumentNotNull(catalogName, nameof(catalogName)); Assert.ArgumentNotNull(productIds, nameof(productIds)); if (priceTypeIds == null) { priceTypeIds = _defaultPriceTypeIds; } var request = new Models.GetProductBulkPricesRequest(catalogName, productIds) { CurrencyCode = CurrencyManager.CurrencyContext.CurrencyCode }; var result = PricingServiceProvider.GetProductBulkPrices(request); // Currently, both Categories and Products are passed in and are waiting for a fix to filter the categories out. Until then, this code is commented // out as it generates an unecessary Error event indicating the product cannot be found. //result.WriteToSitecoreLog(); return(new ManagerResponse <GetProductBulkPricesResult, IDictionary <string, Price> >(result, result.Prices ?? new Dictionary <string, Price>())); }
protected override void RenderContent(PrintContext printContext, XElement output) { string ListPriceKey = "List"; XElement baseXml = new XElement("base"); base.RenderContent(printContext, baseXml); XElement textFrame = baseXml.Element("TextFrame"); Item dataItem = GetDataItem(printContext); XElement xElement = RenderItemHelper.CreateXElement("TextFrame", base.RenderingItem, printContext.Settings.IsClient, dataItem); this.SetAttributes(xElement); output.Add(xElement); XAttribute xAttribute = output.Attribute("ParagraphStyle"); string text = (xAttribute != null && !string.IsNullOrEmpty(xAttribute.Value)) ? xAttribute.Value : "H1 Orange"; Field fieldname = dataItem.Fields[this.ContentFieldName]; DateField dateField = fieldname; var request = new GetProductPricesRequest(dataItem["ExternalID"]); var response = new PricingServiceProvider(); var price = response.GetProductPrices(request).Prices[ListPriceKey].Amount; //var price = response.Prices.ContainsKey(ListPriceKey) ? response.Prices[ListPriceKey].Amount : decimal.Zero; //var price = this.pricingService.GetProductPrice("11"); IEnumerable <XElement> result = this.FormatText(text, price.ToString("c")); xElement.Add(result); this.RenderChildren(printContext, xElement); }
/// <summary> /// Initializes a new instance of the <see cref="PricingManager"/> class. /// </summary> /// <param name="pricingServiceProvider">The pricing service provider.</param> public PricingManager([NotNull] PricingServiceProvider pricingServiceProvider) { Assert.ArgumentNotNull(pricingServiceProvider, "pricingServiceProvider"); this.PricingServiceProvider = pricingServiceProvider; }
/// <summary> /// Initializes a new instance of the <see cref="PricingService"/> class. /// </summary> /// <param name="serviceProvider">The service provider.</param> public PricingService(PricingServiceProvider serviceProvider) { this.serviceProvider = serviceProvider; }
/// <summary> /// Initializes a new instance of the <see cref="PricesServiceTest"/> class. /// </summary> public PricesServiceTest() { this.serviceProvider = Substitute.For <PricingServiceProvider>(); this.pricingService = new PricingService(this.serviceProvider); }
public PricingManager(IConnectServiceProvider connectServiceProvider) { Assert.ArgumentNotNull((object)connectServiceProvider, nameof(connectServiceProvider)); this.pricingServiceProvider = connectServiceProvider.GetPricingServiceProvider(); }