public ProductsController(
     IProductRepository productRepository,
     IProductHandler productHandler)
 {
     _productRepository = productRepository;
     _productHandler    = productHandler;
 }
 public CartHandler(ILiteDbContext liteDbContext, IProductHandler productHandler)
 {
     _liteDatabase    = liteDbContext.Database;
     _cartsCollection = _liteDatabase.GetCollection <Cart>("carts");
     _cartsCollection.EnsureIndex(x => x.CartId);
     _productHandler = productHandler;
 }
 public ProductController(IProductRepository repository, IProductHandler handler,
                          IDistributedCache distributedCache)
 {
     _repository       = repository;
     _handler          = handler;
     _distributedCache = distributedCache;
 }
Beispiel #4
0
 public ProductManager(ICategoryHandler categoryHandler, IProductHandler productHandler, IBalanceManager balanceManager, IPaymentManager paymentManager)
 {
     _categoryHandler = categoryHandler ?? throw new System.ArgumentNullException(nameof(_categoryHandler));
     _productHandler  = productHandler ?? throw new System.ArgumentNullException(nameof(_productHandler));
     _balanceManager  = balanceManager ?? throw new System.ArgumentNullException(nameof(_balanceManager));
     _paymentManager  = paymentManager ?? throw new System.ArgumentNullException(nameof(_paymentManager));
 }
        public CreateProductHandlerTests()
        {
            _productRepository = Substitute.For <IProductRepository>();
            _handler           = new ProductHandler(_productRepository);

            _commandWithoutName = _fixture
                                  .Build <CreateProductCommand>()
                                  .Without(x => x.Name)
                                  .Create();

            _commandWithName = _fixture
                               .Build <CreateProductCommand>()
                               .With(x => x.Name, _fixture.Create <string>())
                               .Create();

            _commandWithPriceZero = _fixture
                                    .Build <CreateProductCommand>()
                                    .With(x => x.Price, 0)
                                    .Create();

            _commandWithPriceGreaterZero = _fixture
                                           .Build <CreateProductCommand>()
                                           .With(x => x.Price, 450)
                                           .Create();
        }
        public async Task <GenericCommandResult <ProductEntity> > Delete(
            [FromBody] DeleteProductCommand command,
            [FromServices] IProductHandler handler)
        {
            var result = (GenericCommandResult <ProductEntity>) await handler.HandleAsync(command);

            return(result);
        }
        public ProductHelper(IProductHandler handler)
        {
            if (handler == null)
            {
                throw new ArgumentException();
            }

            _handler = handler;
        }
Beispiel #8
0
        public ProductHelper(IProductHandler handler)
        {
            if (handler == null)
            {
                throw new ArgumentException();
            }

            _handler = handler;
        }
Beispiel #9
0
 public CsvManager(IWebHostEnvironment hosting, ICsvHandler csv, IGenericRepository <Csv> repository, IProductHandler product, ICsvHelper function, IProtectorHandler protector)
 {
     _hosting    = hosting ?? throw new ArgumentNullException(nameof(_hosting));
     _csvHandler = csv ?? throw new ArgumentNullException(nameof(_csvHandler));
     _repository = repository ?? throw new ArgumentNullException(nameof(_repository));
     _product    = product ?? throw new ArgumentNullException(nameof(_product));
     _csvHelper  = function ?? throw new ArgumentNullException(nameof(_csvHelper));
     _protector  = protector ?? throw new ArgumentNullException(nameof(_protector));
 }
        public HomeController(IProductHandler products)
        {
            if (products == null)
            {
                throw new ArgumentException("products");
            }

            _products = products;
        }
Beispiel #11
0
        public HomeController(IProductHandler products)
        {
            if (products == null)
            {
                throw new ArgumentException("products");
            }

            _products = products;
        }
        public IProductHandler <IProduct, int> GetService(Type t)
        {
            IProductHandler <IProduct, int> handler = null;

            if (t != null)
            {
                _services.TryGetValue(t, out handler);
            }

            return(handler);
        }
Beispiel #13
0
 public ECommerce()
 {
     _Customer               = new Customer();
     _MarketingPerson        = new MarketingPerson();
     _CartHandler            = new CartHandler();
     _AuthenticationHandler  = new AuthenticationHandler();
     _CourierServiceHandler  = new CourierServiceHandler();
     _CustomerHandler        = new CustomerHandler();
     _MarketingPersonHandler = new MarketingPersonHandler();
     _ProductHandler         = new ProductHandler();
     _SalesPersonHandler     = new SalesPersonHandler();
 }
Beispiel #14
0
        public void AddToCart(IProductHandler _ProductHandler)
        {
            Console.WriteLine("Enter the Item Id to Add it to Your cart");
            int ItemId = Convert.ToInt32(Console.ReadLine());

            string name = _ProductHandler.GetProductName(ItemId);
            double cost = _ProductHandler.GetProductCost(ItemId);

            CustomerCartList.Add(new Cart {
                _ItemId = ItemId, _ItemName = name, _ItemCost = cost
            });
        }
        public void AddItemToProductCatalog(IProductHandler _ProductHandler)
        {
            Console.WriteLine("Enter the product ID");
            int Id = Convert.ToInt32(Console.ReadLine());

            Console.WriteLine("Enter the Product Name");
            string Name = Console.ReadLine();

            Console.WriteLine("Enter the product Cost");
            double Cost = Convert.ToDouble(Console.ReadLine());

            _ProductHandler.AddProduct(Id, Name, Cost);
        }
Beispiel #16
0
        public UpdateProductHandlerTests()
        {
            _productRepository = Substitute.For <IProductRepository>();

            var productValid = _fixture.Create <ProductEntity>();

            _productRepository.GetAsync(productValid.Id).Returns(productValid);

            _handler = new ProductHandler(_productRepository);

            _commandWithoutName = _fixture
                                  .Build <UpdateProductCommand>()
                                  .Without(x => x.Name)
                                  .With(x => x.Id, productValid.Id)
                                  .Create();

            _commandWithName = _fixture
                               .Build <UpdateProductCommand>()
                               .With(x => x.Name, _fixture.Create <string>())
                               .With(x => x.Id, productValid.Id)
                               .Create();

            _commandWithPriceZero = _fixture
                                    .Build <UpdateProductCommand>()
                                    .With(x => x.Price, 0)
                                    .With(x => x.Id, productValid.Id)
                                    .Create();

            _commandWithPriceGreaterZero = _fixture
                                           .Build <UpdateProductCommand>()
                                           .With(x => x.Price, 450)
                                           .With(x => x.Id, productValid.Id)
                                           .Create();

            _commandWithInvalidId = _fixture
                                    .Build <UpdateProductCommand>()
                                    .Without(x => x.Id)
                                    .Create();

            _commandWithValidId = _fixture
                                  .Build <UpdateProductCommand>()
                                  .With(x => x.Id, productValid.Id)
                                  .Create();
        }
Beispiel #17
0
        public ActiveProductHandlerTests()
        {
            _productRepository = Substitute.For <IProductRepository>();
            _handler           = new ProductHandler(_productRepository);

            var productValid = _fixture.Create <ProductEntity>();

            _productRepository.GetAsync(productValid.Id).Returns(productValid);

            _commandWithoutId = _fixture
                                .Build <ActiveProductCommand>()
                                .Without(x => x.Id)
                                .Create();

            _commandWithId = _fixture
                             .Build <ActiveProductCommand>()
                             .With(x => x.Id, productValid.Id)
                             .Create();
        }
 public VendingMachineManager(ICoinHandler coinHandler, IProductHandler productHandler)
 {
     _coinHandler    = coinHandler;
     _productHandler = productHandler;
 }
Beispiel #19
0
        public ClientHandler(string basePath, ClientCreateArgs createArgs)
        {
            basePath   = basePath ?? "";
            BasePath   = basePath;
            CreateArgs = createArgs;
            string flavorInfoProductCode = null;

            if (createArgs.UseContainer && !Directory.Exists(basePath))
            {
                throw new FileNotFoundException("invalid archive directory");
            }

            var dbPath = Path.Combine(basePath, createArgs.ProductDatabaseFilename);

            try {
                if (File.Exists(dbPath))
                {
                    using (var _ = new PerfCounter("AgentDatabase::ctor`string`bool"))
                        foreach (var install in new AgentDatabase(dbPath).Data.ProductInstall)
                        {
                            if (string.IsNullOrEmpty(createArgs.Flavor) || install.Settings.GameSubfolder.Contains(createArgs.Flavor))
                            {
                                AgentProduct = install;
                                break;
                            }
                        }

                    if (AgentProduct == null)
                    {
                        throw new InvalidDataException();
                    }

                    Product = ProductHelpers.ProductFromUID(AgentProduct.ProductCode);
                }
                else
                {
                    throw new InvalidDataException();
                }
            } catch {
                try {
                    if (File.Exists(Path.Combine(basePath, ".flavor.info")))
                    {
                        // mixed installation, store the product code to be used below
                        flavorInfoProductCode = File.ReadLines(Path.Combine(basePath, ".flavor.info")).Skip(1).First();
                        Product  = ProductHelpers.ProductFromUID(flavorInfoProductCode);
                        BasePath = basePath = Path.Combine(basePath, "../"); // lmao

                        Logger.Info("Core", $".flavor.info detected. Found product \"{flavorInfoProductCode}\"");
                    }
                    else
                    {
                        throw new InvalidDataException();
                    }
                } catch {
                    try {
                        Product = ProductHelpers.ProductFromLocalInstall(basePath);
                    } catch {
                        if (createArgs.VersionSource == ClientCreateArgs.InstallMode.Local)    // if we need an archive then we should be able to detect the product
                        {
                            throw;
                        }

                        Product = createArgs.OnlineProduct;
                    }
                }

                AgentProduct = new ProductInstall {
                    ProductCode = flavorInfoProductCode ?? createArgs.Product ?? ProductHelpers.UIDFromProduct(Product),
                    Settings    = new UserSettings {
                        SelectedTextLanguage   = createArgs.TextLanguage ?? "enUS",
                        SelectedSpeechLanguage = createArgs.SpeechLanguage ?? "enUS",
                        PlayRegion             = "us"
                    }
                };

                if (AgentProduct.Settings.SelectedSpeechLanguage == AgentProduct.Settings.SelectedTextLanguage)
                {
                    AgentProduct.Settings.Languages.Add(new LanguageSetting {
                        Language = AgentProduct.Settings.SelectedTextLanguage,
                        Option   = LanguageOption.LangoptionTextAndSpeech
                    });
                }
                else
                {
                    AgentProduct.Settings.Languages.Add(new LanguageSetting {
                        Language = AgentProduct.Settings.SelectedTextLanguage,
                        Option   = LanguageOption.LangoptionText
                    });

                    AgentProduct.Settings.Languages.Add(new LanguageSetting {
                        Language = AgentProduct.Settings.SelectedSpeechLanguage,
                        Option   = LanguageOption.LangoptionSpeech
                    });
                }
            }

            if (string.IsNullOrWhiteSpace(createArgs.TextLanguage))
            {
                createArgs.TextLanguage = AgentProduct.Settings.SelectedTextLanguage;
            }

            if (string.IsNullOrWhiteSpace(createArgs.SpeechLanguage))
            {
                createArgs.SpeechLanguage = AgentProduct.Settings.SelectedSpeechLanguage;
            }

            if (createArgs.Online)
            {
                using var _ = new PerfCounter("INetworkHandler::ctor`ClientHandler");
                if (createArgs.OnlineRootHost.StartsWith("ribbit:"))
                {
                    NetHandle = new RibbitCDNClient(this);
                }
                else
                {
                    NetHandle = new NGDPClient(this);
                }
            }

            if (createArgs.VersionSource == ClientCreateArgs.InstallMode.Local)
            {
                var installationInfoPath = Path.Combine(basePath, createArgs.InstallInfoFileName) + createArgs.ExtraFileEnding;
                if (!File.Exists(installationInfoPath))
                {
                    throw new FileNotFoundException(installationInfoPath);
                }

                using var _      = new PerfCounter("InstallationInfo::ctor`string");
                InstallationInfo = new InstallationInfo(installationInfoPath, AgentProduct.ProductCode);
            }
            else
            {
                using var _      = new PerfCounter("InstallationInfo::ctor`INetworkHandler");
                InstallationInfo = new InstallationInfo(NetHandle, createArgs.OnlineRegion);
            }

            Logger.Info("CASC", $"{Product} build {InstallationInfo.Values["Version"]}");

            if (createArgs.UseContainer)
            {
                Logger.Info("CASC", "Initializing...");
                using var _      = new PerfCounter("ContainerHandler::ctor`ClientHandler");
                ContainerHandler = new ContainerHandler(this);
            }

            using (var _ = new PerfCounter("ConfigHandler::ctor`ClientHandler"))
                ConfigHandler = new ConfigHandler(this);

            using (var _ = new PerfCounter("EncodingHandler::ctor`ClientHandler"))
                EncodingHandler = new EncodingHandler(this);

            if (ConfigHandler.BuildConfig.VFSRoot != null)
            {
                using var _ = new PerfCounter("VFSFileTree::ctor`ClientHandler");
                VFS         = new VFSFileTree(this);
            }

            if (createArgs.Online)
            {
                m_cdnIdx = CDNIndexHandler.Initialize(this);
            }

            using (var _ = new PerfCounter("ProductHandlerFactory::GetHandler`TACTProduct`ClientHandler`Stream"))
                ProductHandler = ProductHandlerFactory.GetHandler(Product, this, OpenCKey(ConfigHandler.BuildConfig.Root.ContentKey));

            Logger.Info("CASC", "Ready");
        }
Beispiel #20
0
 public ProductController(IProductHandler productHandler)
 {
     this._productHandler = productHandler;
 }
Beispiel #21
0
 public ItemHandler(IProductHandler handler)
 {
     _handler = handler ?? throw new ArgumentNullException(nameof(_handler));
 }
Beispiel #22
0
 public PaymentHandler(IProductHandler productHandler)
 {
     _productHandler = productHandler ?? throw new ArgumentNullException(nameof(_productHandler));
 }
Beispiel #23
0
 public MoviesController(IProductHandler <MovieDto, MovieDetailDto> handler)
 {
     this.handler = handler;
 }
Beispiel #24
0
 public PaymentManager(IProductHandler productHandler) =>
Beispiel #25
0
 public ProductsController(IProductManager productManager, IProductHandler productHandler)
 {
     _productHandler = productHandler ?? throw new System.ArgumentNullException(nameof(_productHandler));
     _productManager = productManager ?? throw new System.ArgumentNullException(nameof(productManager));
 }
Beispiel #26
0
 public Products(IProductHandler prodHandler)
 {
     _prodHandler = prodHandler;
     _nameFilter  = string.Empty;
 }
Beispiel #27
0
 public ProductController(IProductService productService, IProductHandler productHandler, IMapper mapper)
 {
     _productService = productService;
     _productHandler = productHandler;
     _mapper         = mapper;
 }
Beispiel #28
0
 public ProductsController(IProductsRepo productsRepo)
 {
     _prodHandler       = productsRepo.GetProductHandler();
     _prodOptionHandler = productsRepo.GetProductOptionHandler();
     _prodRepo          = productsRepo;
 }
 public ProductController(IProductRepository repository, IProductHandler handler)
 {
     _repository = repository;
     _handler    = handler;
 }
 public ProductController(IProductHandler handler, IProductQuery query, IMapper mapper)
 {
     _handler = handler;
     _query   = query;
     _mapper  = mapper;
 }
Beispiel #31
0
 public ProductRepository(IProductHandler productHandler)
 {
     _productHandler = productHandler;
 }
Beispiel #32
0
 public ProductsController(IProductHandler productHandler)
 {
     _productHandler = productHandler;
 }