public InventoryManager(IConnectServiceProvider connectServiceProvider, ILogService <CommonLog> logService)
            : base(logService)
        {
            Assert.ArgumentNotNull(connectServiceProvider, nameof(connectServiceProvider));

            this.inventoryServiceProvider = connectServiceProvider.GetInventoryServiceProvider();
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="InventoryServiceTest"/> class.
 /// </summary>
 public InventoryServiceTest()
 {
     this._serviceProvider = Substitute.For <InventoryServiceProvider>();
     this._contactFactory  = Substitute.For <ContactFactory>();
     this._contactFactory.GetContact().Returns("John Doe");
     this._inventoryService = new InventoryService(this._serviceProvider, this._contactFactory);
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="InventoryManager" /> class.
        /// </summary>
        /// <param name="inventoryServiceProvider">The inventory service provider.</param>
        /// <param name="contactFactory">The contact factory.</param>
        public InventoryManager([NotNull] InventoryServiceProvider inventoryServiceProvider, [NotNull] ContactFactory contactFactory)
        {
            Assert.ArgumentNotNull(inventoryServiceProvider, "inventoryServiceProvider");
            Assert.ArgumentNotNull(contactFactory, "contactFactory");

            this.InventoryServiceProvider = inventoryServiceProvider;
            this.ContactFactory           = contactFactory;
            this._obecContext             = (CommerceContextBase)Factory.CreateObject("commerceContext", true);
        }
        public InventoryManager(InventoryServiceProvider inventoryServiceProvider, ContactFactory contactFactory, ICommerceSearchManager commerceSearchManager, StorefrontContext storefrontContext)
        {
            Assert.ArgumentNotNull(inventoryServiceProvider, nameof(inventoryServiceProvider));
            Assert.ArgumentNotNull(contactFactory, nameof(contactFactory));

            InventoryServiceProvider = inventoryServiceProvider;
            ContactFactory           = contactFactory;
            _obecContext             = (CommerceContextBase)Factory.CreateObject("commerceContext", true);
            CommerceSearchManager    = commerceSearchManager;
            StorefrontContext        = storefrontContext;
        }
Exemple #5
0
        public InventoryManagerTests()
        {
            var connectServiceProvider = Substitute.For <IConnectServiceProvider>();

            this.inventoryServiceProvider = Substitute.For <InventoryServiceProvider>();

            connectServiceProvider.GetInventoryServiceProvider().Returns(this.inventoryServiceProvider);

            this.logService = Substitute.For <ILogService <CommonLog> >();
            this.fixture    = new Fixture();

            this.inventoryManager = Substitute.For <InventoryManager>(connectServiceProvider, this.logService);
        }
        public ManagerResponse <GetBackOrderableInformationResult, IEnumerable <OrderableInformation> > GetBackOrderableInformation(IEnumerable <InventoryProduct> products)
        {
            Assert.ArgumentNotNull(products, nameof(products));
            if (StorefrontContext.Current == null)
            {
                throw new InvalidOperationException("Cannot be called without a valid storefront context.");
            }

            var request = new GetBackOrderableInformationRequest(StorefrontContext.Current.ShopName, products);
            var result  = InventoryServiceProvider.GetBackOrderableInformation(request);

            result.WriteToSitecoreLog();
            return(new ManagerResponse <GetBackOrderableInformationResult, IEnumerable <OrderableInformation> >(result, !result.Success || result.OrderableInformation == null ? new List <OrderableInformation>() : result.OrderableInformation));
        }
Exemple #7
0
        public InventoryService(InventoryServiceProvider inventoryServiceProvider, IExceptionLogger exceptionLogger)
        {
            if (inventoryServiceProvider == null)
            {
                throw new ArgumentNullException("inventoryServiceProvider");
            }
            if (exceptionLogger == null)
            {
                throw new ArgumentNullException("exceptionLogger");
            }

            _inventoryServiceProvider = inventoryServiceProvider;
            _exceptionLogger          = exceptionLogger;
        }
        /// <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 <VisitedProductStockStatusResult, bool> VisitedProductStockStatus(StockInformation stockInformation, string location)
        {
            Assert.ArgumentNotNull(stockInformation, nameof(stockInformation));

            if (StorefrontContext.Current == null)
            {
                throw new InvalidOperationException("Cannot be called without a valid storefront context.");
            }

            var request = new VisitedProductStockStatusRequest(StorefrontContext.Current.ShopName, stockInformation)
            {
                Location = location
            };
            var result = InventoryServiceProvider.VisitedProductStockStatus(request);

            result.WriteToSitecoreLog();
            return(new ManagerResponse <VisitedProductStockStatusResult, bool>(result, result.Success));
        }
        public ManagerResponse <GetStockInformationResult, IEnumerable <StockInformation> > GetStockInformation(IEnumerable <InventoryProduct> products, StockDetailsLevel detailsLevel)
        {
            Assert.ArgumentNotNull(products, nameof(products));
            if (StorefrontContext.Current == null)
            {
                throw new InvalidOperationException("Cannot be called without a valid storefront context.");
            }

            var request = new GetStockInformationRequest(StorefrontContext.Current.ShopName, products, detailsLevel)
            {
                Location = _obecContext.InventoryLocation, VisitorId = ContactFactory.GetContact()
            };
            var result = InventoryServiceProvider.GetStockInformation(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 <GetStockInformationResult, IEnumerable <StockInformation> >(result, result.StockInformation ?? new List <StockInformation>()));
        }
        public ManagerResponse <VisitorSignUpForStockNotificationResult, bool> VisitorSignupForStockNotification(SignUpForNotificationInputModel model, string location)
        {
            Assert.ArgumentNotNull(model, nameof(model));
            Assert.ArgumentNotNullOrEmpty(model.ProductId, nameof(model.ProductId));
            Assert.ArgumentNotNullOrEmpty(model.Email, nameof(model.Email));
            if (StorefrontContext.Current == null)
            {
                throw new InvalidOperationException("Cannot be called without a valid storefront context.");
            }

            var visitorId        = ContactFactory.GetContact();
            var builder          = new CommerceInventoryProductBuilder();
            var inventoryProduct = (CommerceInventoryProduct)builder.CreateInventoryProduct(model.ProductId);

            if (string.IsNullOrEmpty(model.VariantId))
            {
                inventoryProduct.VariantId = model.VariantId;
            }

            if (string.IsNullOrEmpty(inventoryProduct.CatalogName))
            {
                inventoryProduct.CatalogName = model.CatalogName;
            }

            DateTime interestDate;
            var      isDate  = DateTime.TryParse(model.InterestDate, out interestDate);
            var      request = new VisitorSignUpForStockNotificationRequest(StorefrontContext.Current.ShopName, visitorId, model.Email, inventoryProduct)
            {
                Location = location
            };

            if (isDate)
            {
                request.InterestDate = interestDate;
            }

            var result = InventoryServiceProvider.VisitorSignUpForStockNotification(request);

            result.WriteToSitecoreLog();
            return(new ManagerResponse <VisitorSignUpForStockNotificationResult, bool>(result, result.Success));
        }
 public InventoryManager(IConnectServiceProvider connectServiceProvider)
 {
     Assert.ArgumentNotNull(connectServiceProvider, nameof(connectServiceProvider));
     this.inventoryServiceProvider = connectServiceProvider.GetInventoryServiceProvider();
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="InventoryService"/> class.
 /// </summary>
 /// <param name="serviceProvider">The service provider.</param>
 /// <param name="contactFactory">The visitor factory.</param>
 public InventoryService(InventoryServiceProvider serviceProvider, ContactFactory contactFactory)
 {
     this._serviceProvider = serviceProvider;
     this._contactFactory  = contactFactory;
 }
Exemple #15
0
 public MockInventoryManager(InventoryServiceProvider inventoryServiceProvider, IContactFactory contactFactory)
 {
     _inventoryServiceProvider = inventoryServiceProvider;
     _contactFactory           = contactFactory;
 }