예제 #1
0
 public ViewModelFactory(IEventBus eventBus,
                         IAgentRepository agentRepo, IProductRepository productRepo,
                         IProductPriceManager productPriceMng,
                         IProductStatusProvider statusProvider,
                         IUserInteraction ui)
 {
     _eventBus        = eventBus;
     _agentRepo       = agentRepo;
     _productRepo     = productRepo;
     _productPriceMng = productPriceMng;
     _statusProvider  = statusProvider;
     _ui = ui;
 }
예제 #2
0
        /// <summary>
        /// Gets the general price.
        /// </summary>
        /// <param name="ni">The ni.</param>
        /// <returns>The general price.</returns>
        private Totals GetProductTotals(XPathNodeIterator ni)
        {
            Item item = this.GetItem(ni);

            Assert.ArgumentNotNull(item, "item");

            IProductRepository productProvider = Context.Entity.Resolve <IProductRepository>();

            ProductBaseData product = productProvider.Get <ProductBaseData>(item["Product Code"]);

            if (product != null)
            {
                ShoppingCart         shoppingCart        = Context.Entity.GetInstance <ShoppingCart>();
                IProductPriceManager productPriceManager = Context.Entity.Resolve <IProductPriceManager>();
                Totals productPricesList = productPriceManager.GetProductTotals <Totals, ProductBaseData, Currency>(product, shoppingCart.Currency);

                return(productPricesList);
            }

            return(default(Totals));
        }
 public ProductPriceController()
 {
     _aManager = new ProductPriceManager();
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ShoppingCartManager"/> class.
 /// </summary>
 /// <param name="productRepository">The product repository.</param>
 /// <param name="productPriceManager">The product price manager.</param>
 public ShoppingCartManager(IProductRepository productRepository, IProductPriceManager productPriceManager)
 {
   this.shoppingCart = Context.Entity.GetInstance<DomainModel.Carts.ShoppingCart>();
   this.productPriceManager = productPriceManager;
   this.productRepository = productRepository;
 }
예제 #5
0
        public TrackerProductViewModel(Product product, IEventBus eventBus,
                                       IAgentRepository agentRepo, IProductPriceManager productMng,
                                       IProductRepository productRepo, IProductStatusProvider statusProvider,
                                       IUserInteraction ui)
        {
            _agentRepo      = agentRepo;
            _productMng     = productMng;
            _productRepo    = productRepo;
            _statusProvider = statusProvider;
            _product        = product;
            _ui             = ui;

            RefreshAgents();
            RefreshCategories();

            if (_product != null)
            {
                ResetForm();
                Reconcile(false);
            }

            CommitProductCommand = new ActionCommand(_ => CommitProduct());

            ShowInBrowserCommand = new ActionCommand(_ =>
                                                     ui.ShowProductInBrowser(_product.Lowest?.ProductSource));

            AddSourceCommand = new ActionCommand(_ =>
                                                 Sources.Add(CreateSourceViewModel(null)));

            ResetCommand = new ActionCommand(_ => {
                ResetForm();
            }, _ => _product != null);

            DropPricesCommand = new ActionCommand(_ => {
                if (!_ui.AskForConfirmation("Are you sure?", "Prices drop confirmation"))
                {
                    return;
                }
                _productRepo.DropPrices(_product);
                Reconcile(true);
            });

            RefreshPriceCommand = new ActionCommand(_ => {
                if (Status == ProductScanStatus.Scanning)
                {
                    return;
                }
                _productMng.EnqueueScan(product.Id);
            }, _ => Status != ProductScanStatus.Scanning);

            eventBus.WhenFired <AgentsUpdatedEvent, AgentDeletedEvent>()
            .ObserveOnDispatcher()
            .Subscribe(_ =>
                       RefreshAgents()
                       );
            eventBus.WhenFired <ProductUpdatedEvent, ProductAddedEvent>()
            .ObserveOnDispatcher()
            .Subscribe(_ =>
                       RefreshCategories()
                       );

            PropertiesAreInitialized = true;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="ProductDetailsPresenterTest" /> class.
        /// </summary>
        public ProductDetailsPresenterTest()
        {
            this.view = Substitute.For<IProductDetailsView>();

              this.product = new Product { Code = "d3" };

              this.productRepository = Substitute.For<IProductRepository>();
              this.productRepository.Get<Product>("d3").Returns(this.product);

              this.priceManager = Substitute.For<IProductPriceManager>();
              this.priceManager.GetProductTotals<Totals, Product, Currency>(this.product, null).Returns(new Totals { PriceExVat = 7.00m });

              this.stockManager = Substitute.For<IProductStockManager>();
              this.stockManager.GetStock(Arg.Is<ProductStockInfo>(p => p.ProductCode == "d3")).Returns(new Products.ProductStock { Code = "d3", Stock = 5 });

              this.orderManager = Substitute.For<VisitorOrderManager>();
              this.httpContext = Substitute.For<HttpContextBase>();

              new ProductDetailsPresenter(this.view, this.productRepository, this.stockManager, this.priceManager, this.orderManager) { HttpContext = this.httpContext };
        }
예제 #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ShoppingCartManager"/> class.
 /// </summary>
 /// <param name="productRepository">The product repository.</param>
 /// <param name="productPriceManager">The product price manager.</param>
 public ShoppingCartManager(IProductRepository productRepository, IProductPriceManager productPriceManager)
 {
     this.shoppingCart        = Context.Entity.GetInstance <DomainModel.Carts.ShoppingCart>();
     this.productPriceManager = productPriceManager;
     this.productRepository   = productRepository;
 }