示例#1
0
        static void Main(string[] args)
        {
            IProductStorage storage = new ProductStorage();

            Product p0 = storage.GetById(1);

            Console.WriteLine(p0);
            Product p1 = storage.GetById(1);

            Console.WriteLine(p1);
            Product p2 = storage.GetById(3);

            Console.WriteLine(p2);
            Product p3 = storage.GetById(1);

            Console.WriteLine(p3);
            Product p4 = storage.GetById(1);

            Console.WriteLine(p4);
            Product p5 = storage.GetById(1);

            Console.WriteLine(p5);
            Product p6 = storage.GetById(3);

            Console.WriteLine(p6);
        }
 public void Text(ProductStorage productStorage)
 {
     if (productStorage != null)
     {
         _amountText.text = productStorage.Amount + "/" + productStorage.MaxAmount;
     }
 }
示例#3
0
    private IEnumerator UpdateUI()
    {
        ProductStorage emitterStorage = _productProcessorBehaviour.EmitterStorage();
        Dictionary <ProductData, AmountProductView> _amountProductViewDict =
            new Dictionary <ProductData, AmountProductView>();

        for (int i = 0; i < _factoryNeededProductView.ScrollView.childCount; i++)
        {
            AmountProductView productView = _factoryNeededProductView.ScrollView.GetChild(i).gameObject
                                            .GetComponent <AmountProductView>();

            ProductStorage receiverStorage = _productProcessorBehaviour.ReceiverStorage(productView.ProductData);
            if (receiverStorage == null)
            {
                continue;
            }
            productView.Text(receiverStorage);
        }

        _amountLabel.text    = emitterStorage.Amount + "/" + emitterStorage.MaxAmount;
        _productImage.sprite = emitterStorage.StoredProductData.ProductSprite;

        while (_productProcessorBehaviour && VisibleObject.activeSelf)
        {
//            _productionTimeSlider.value = _factory.ProductionProgress;
            yield return(null);
        }

        _amountLabel.text           = "Factory View";
        _productImage.sprite        = _defaultProductSprite;
        _productionTimeSlider.value = 0;
        yield return(null);
    }
示例#4
0
        /// <summary>
        /// Добавляет продукт на склад(если он уже есть на складе, то прибавляет количество)
        /// </summary>
        /// <returns></returns>
        public async Task AddAsync(ProductStorageModel model)
        {
            if (model == null)
            {
                throw new NullReferenceException($"Ссылка на модель равняется null.");
            }

            var result = await _context.ProductStorages.SingleOrDefaultAsync(x =>
                                                                             x.IdProduct == model.IdProduct && x.IdStorage == model.IdStorage);

            if (result != null)
            {
                result.ProductCount += model.ProductCount;
            }
            else
            {
                result = new ProductStorage
                {
                    IdProduct    = model.IdProduct,
                    IdStorage    = model.IdStorage,
                    ProductCount = model.ProductCount
                };
                await _context.ProductStorages.AddAsync(result);
            }
            await _context.SaveChangesAsync();
        }
示例#5
0
 public ConsumerController(DatabaseInterface db)
 {
     _db      = db;
     _product = new ProductStorage(db);
     _user    = new CustomerStorage(db);
     _orders  = new OrderAccess(db);
 }
        /**
         * Tests to see if the productStorage.OnAmountChange callbacks function correctly.
         */
        public IEnumerator ProductStorageTest_CorrectCallbackAmounts()
        {
            ProductData    productData    = Resources.Load <ProductData>("Data/ProductData/Wheat");
            ProductStorage productStorage = new ProductStorage(productData, 10);

            // For verification
            int amountOfCallbacks     = 0;
            int callbackProductAmount = productStorage.Amount;
            // For test procedure
            int amountOfAddedProducts = 10;
            int transferAmount        = Random.Range(1, 5);

            productStorage.OnAmountChange += (storage, amount) => amountOfCallbacks++;
            productStorage.OnAmountChange += (storage, amount) => callbackProductAmount += amount;

            for (int i = 0; i < amountOfAddedProducts; i++)
            {
                if (productStorage.Amount + transferAmount > productStorage.MaxAmount)
                {
                    Assert.Throws <OverflowException>(() => productStorage.Add(transferAmount));
                }
                else
                {
                    productStorage.Add(transferAmount);
                }
            }

            Assert.AreEqual(amountOfAddedProducts / transferAmount, amountOfCallbacks);
            Assert.AreEqual(productStorage.Amount, callbackProductAmount);
            yield return(null);
        }
示例#7
0
        public void ShoppingCartAddProductTest()
        {
            var products = new List <IProduct>();

            products.Add(new Product {
                Name = "Test", UnitPrice = 1
            });
            products.Add(new Product {
                Name = "Test2", UnitPrice = 2
            });


            var productStorage  = new ProductStorage(products);
            var discountStorage = new DiscountStorage(new List <IDiscount>());

            //checking that by default the cart is empty
            var shoppingCart = new ShoppingCart(productStorage, discountStorage);
            var testItems    = shoppingCart.GetShoppingCartItems();

            Assert.IsNotNull(testItems);
            Assert.AreEqual(0, testItems.Count);

            //basic add functionality test
            shoppingCart.AddProduct("Test", 1);
            shoppingCart.AddProduct("Test2", 1);

            testItems = shoppingCart.GetShoppingCartItems();
            Assert.IsNotNull(testItems);
            var testItem = testItems.FirstOrDefault(x => x.Product.Name == "Test");

            TestUtil.AssertEqualShoppingCartItems(testItem, new ShoppingCartItem {
                Product = new Product {
                    Name = "Test", UnitPrice = 1
                }, Quantity = 1
            });
            var testItem2 = testItems.FirstOrDefault(x => x.Product.Name == "Test2");

            TestUtil.AssertEqualShoppingCartItems(testItem2, new ShoppingCartItem {
                Product = new Product {
                    Name = "Test2", UnitPrice = 2
                }, Quantity = 1
            });

            //items grouping test
            shoppingCart.AddProduct("Test", 5);
            testItems = shoppingCart.GetShoppingCartItems();
            testItem  = testItems.FirstOrDefault(x => x.Product.Name == "Test");
            TestUtil.AssertEqualShoppingCartItems(testItem, new ShoppingCartItem {
                Product = new Product {
                    Name = "Test", UnitPrice = 1
                }, Quantity = 6
            });
            testItem2 = testItems.FirstOrDefault(x => x.Product.Name == "Test2");
            TestUtil.AssertEqualShoppingCartItems(testItem2, new ShoppingCartItem {
                Product = new Product {
                    Name = "Test2", UnitPrice = 2
                }, Quantity = 1
            });
        }
 public void Delete(IDbConnection connection, ProductStorage productStorage, IDbTransaction transaction = null)
 {
     connection.Execute(ProductStorageQueries.Delete, new
     {
         productId = productStorage.ProductId.Content,
         storageId = productStorage.StorageId.Content
     });
 }
示例#9
0
 public void RemoveProductFromStorage(ProductStorageDto productStorageDto)
 {
     using (NpgsqlConnection connection = this.databaseConnectionFactory.Instance.Create())
     {
         ProductStorage productStorage = this.dtoToEntityMapper.Map <ProductStorageDto, ProductStorage>(productStorageDto);
         this.productStorageService.Delete(connection, productStorage);
     }
 }
示例#10
0
        public void AddProductToProductStoragePass()
        {
            Product        p  = new Product("Testprodukt", 1, "Testdescription", 1.0f, new BoxSize(1, 1, 1), true);
            ProductStorage ps = new ProductStorage();

            ps.AddNewProduct(p);
            Assert.AreEqual(ps.ProductCount(), 1);
        }
 public void Insert(IDbConnection connection, ProductStorage productStorage, IDbTransaction transaction = null)
 {
     connection.Execute(ProductStorageQueries.Insert, new
     {
         productId       = productStorage.ProductId.Content,
         storageId       = productStorage.StorageId.Content,
         amountOfProduct = productStorage.AmountOfProduct.Content
     });
 }
示例#12
0
        public void RemoveProductFromStoragePass()
        {
            Product        p  = new Product("Testprodukt", 1, "Testdescription", 1.0, new BoxSize(1, 1, 1), true);
            ProductStorage ps = new ProductStorage();

            ps.AddNewProduct(p);
            ps.RemoveProductID(1);
            Assert.AreEqual(ps.ProductCount(), 0);
        }
示例#13
0
 public Lender(string integrationToken) : base(integrationToken)
 {
     Loans    = new LoanStorage(this);
     Orders   = new OrderStorage(this);
     Products = new ProductStorage(this);
     Users    = new UserStorage(this);
     Vendors  = new VendorStorage(this);
     Apps     = new AppStorage(this);
     Evaults  = new EvaultStorage(this);
 }
    private ProductStorage _producedProduct;                          // The currently produced product

    public ProductProcessorController([NotNull] ProductData producedProduct, int maxAmount)
    {
        _neededProducts = new Dictionary <ProductData, ProductStorage>();
        foreach (NeededProduct neededProduct in producedProduct.NeededProduct)
        {
            _neededProducts.Add(neededProduct.Product, new ProductStorage(neededProduct.Product, maxAmount));
        }

        _producedProduct = new ProductStorage(producedProduct, maxAmount);
    }
示例#15
0
        public ProductStorage GetProductStorage(Guid productId)
        {
            var productBatches = _dbContext.ProductBatches.Where(x => x.ProductId == productId);
            var additionEvents = _dbContext.AdditionEvents.Where(x => x.ProductBatch.ProductId == productId);
            var removalEvents  = _dbContext.RemovalEvents.Where(x => x.ProductBatch.ProductId == productId);

            var productStorage = new ProductStorage(productBatches, additionEvents, removalEvents);

            return(productStorage);
        }
示例#16
0
        public void SortProductsByNamePass()
        {
            ProductStorage ps = new ProductStorage();
            Product        p1 = new Product("Testprodukt", 1, "Testdescription", 1.0f, new BoxSize(1, 1, 1), true);
            Product        p2 = new Product("ABC produkt", 1, "Testdescription", 1.0f, new BoxSize(1, 1, 1), true);

            ps.AddNewProduct(p1);
            ps.AddNewProduct(p2);

            List <Product> sortedlist = ps.ProductsSortedByName();

            Assert.AreEqual(sortedlist[0].ProductName, "ABC produkt");
        }
示例#17
0
        public void ShoppingCartAddProductValidationTest()
        {
            var products = new List <IProduct>();

            products.Add(new Product {
                Name = "Test", UnitPrice = 1
            });
            products.Add(new Product {
                Name = "Test2", UnitPrice = 2
            });


            var productStorage  = new ProductStorage(products);
            var discountStorage = new DiscountStorage(new List <IDiscount>());

            var shoppingCart = new ShoppingCart(productStorage, discountStorage);

            //add unknown product
            try
            {
                shoppingCart.AddProduct("Test3", 1);
                Assert.Fail();
            }
            catch (Exception e)
            {
                Assert.IsInstanceOfType(e, typeof(ArgumentException));
            }

            //add zero quantity
            try
            {
                shoppingCart.AddProduct("Test", 0);
                Assert.Fail();
            }
            catch (Exception e)
            {
                Assert.IsInstanceOfType(e, typeof(ArgumentException));
            }

            //add negative quantity
            try
            {
                shoppingCart.AddProduct("Test2", -3);
                Assert.Fail();
            }
            catch (Exception e)
            {
                Assert.IsInstanceOfType(e, typeof(ArgumentException));
            }
        }
示例#18
0
 private void SetMainStorages()
 {
     upload   = new UploadStorage(ref connection, ref locker);
     category = new CategoryStorage(ref connection, ref locker);
     price    = new PriceStorage(ref connection, ref locker);
     product  = new ProductStorage(ref connection, ref locker);
     log      = new LogStorage(ref connection, ref locker);
     storages.Add(log);
     storages.Add(product);
     storages.Add(upload);
     storages.Add(price);
     storages.Add(category);
     CheckTableExists(files_Create);
 }
示例#19
0
 private IEnumerator UpdateUi()
 {
     while (_transportVehicle != null)
     {
         for (int i = 0; i < _scrollView.childCount; i++)
         {
             AmountProductView productView    = _scrollView.GetChild(i).gameObject.GetComponent <AmountProductView>();
             ProductStorage    productStorage = _transportVehicle.TransportStorage(productView.ProductData);
             productView.Text(productStorage);
         }
         yield return(new WaitForSeconds(1));
     }
     _coroutine = null;
 }
        private bool PreSelectedUpdate(ProductStorage entity, ref bool weNeedPreselected)
        {
            if (_miscOneSSetting.PublishOnlyBerikolesaStorage)
            {
                return(String.Equals(entity.Name, "Berikolesa.RU", StringComparison.CurrentCultureIgnoreCase));
            }

            if (entity.Quantity <= 0 || !weNeedPreselected)
            {
                return(false);
            }

            weNeedPreselected = false;
            return(true);
        }
    /// <summary>
    /// This function loads products from a <see cref="IProductEmitter"/> into the _transporterStorage.
    /// </summary>
    /// <param name="transportRouteElement">The current <see cref="TransportRouteElement"/> that is used by the <see cref="RouteMover"/>.</param>
    /// <returns></returns>
    public IEnumerator Load(TransportRouteElement transportRouteElement)
    {
        if (!(transportRouteElement.FromNode.gameObject.GetComponent <IProductEmitter>() is IProductEmitter producer))
        {
            yield break;
        }
//        Debug.Log(producer.EmitterStorage().StoredProductData.ProductName);
        // Search unloading settings and execute them
        foreach (TransportRouteSetting setting in transportRouteElement.RouteSettings)
        {
            bool isUnload = !setting.IsLoad;
            bool isEmitterProducingProduct = producer.EmitterStorage(setting.ProductData) != null;

            if (isUnload || !isEmitterProducingProduct)
            {
                continue;
            }

            Debug.Log(setting.ToString());

            if (!_transporterStorage.ContainsKey(setting.ProductData))
            {
                ProductStorage productStorage = new ProductStorage(setting.ProductData)
                {
                    MaxAmount = MaxCapacity
                };
                productStorage.SetAmount(0);
                _transporterStorage.Add(setting.ProductData, productStorage);
            }

            // Handle actual unloading process
            ProductStorage emitterStorage = producer.EmitterStorage(setting.ProductData);
            ProductStorage truckStorage   = _transporterStorage[setting.ProductData];
            int            loadAmount     = setting.Amount;
            while (loadAmount > 0 && truckStorage.Amount != truckStorage.MaxAmount)
            {
                while (producer.EmitterStorage(setting.ProductData).Amount == 0)
                {
                    yield return(new WaitForSeconds(0.1f));
                }

                loadAmount--;
                emitterStorage.Add(-TransferAmount);
                truckStorage.Add(TransferAmount);
                yield return(new WaitForSeconds(TransferTime));
            }
        }
    }
示例#22
0
        public bool AddProductStorage(ProductStorage productStorage)
        {
            var result = false;

            try
            {
                var pars = new List <SqlParameter>();
                pars.Add(new SqlParameter("@productID", productStorage.Product.PID));
                pars.Add(new SqlParameter("@number", productStorage.Number));
                pars.Add(new SqlParameter("@userID", productStorage.CreateUser.UID));
                result = SQLHelper.ExcuteProc("[AddProductStorage]", pars.ToArray()) == 1;
            }
            catch (Exception ex)
            {
            }
            return(result);
        }
示例#23
0
    public ProductStorage GetProductStorage(string productName, int maxAmount)
    {
        foreach (ProductData product in products)
        {
            if (product.ProductName.Equals(productName))
            {
                ProductStorage output = new ProductStorage
                {
                    StoredProductData = product,
                    MaxAmount         = maxAmount,
                };
                output.SetAmount(0);
                return(output);
            }
        }

        return(null);
    }
示例#24
0
        public void ShoppingCartItemsGetterTest()
        {
            var products = new List <IProduct>();

            products.Add(new Product {
                Name = "Test", UnitPrice = 1
            });
            var productStorage  = new ProductStorage(products);
            var discountStorage = new DiscountStorage(new List <IDiscount>());

            var shoppingCart = new ShoppingCart(productStorage, discountStorage);
            var testItems    = shoppingCart.GetShoppingCartItems();

            Assert.IsNotNull(testItems);
            Assert.AreEqual(0, testItems.Count);

            shoppingCart.AddProduct("Test", 1);
            testItems = shoppingCart.GetShoppingCartItems();
            Assert.IsNotNull(testItems);
            Assert.AreEqual(1, testItems.Count);

            // add neew item and change existing item
            testItems.Add(new ShoppingCartItem {
                Product = new Product {
                    Name = "Test2", UnitPrice = 2
                }, Quantity = 1
            });
            var testItem = testItems.FirstOrDefault(x => x.Product.Name == "Test");

            Assert.IsNotNull(testItem);
            testItem.Quantity = 500;

            // check that the items in the shopping cart are intact
            var newTestItems = shoppingCart.GetShoppingCartItems();

            Assert.IsNotNull(newTestItems);
            Assert.AreEqual(1, newTestItems.Count);
            var newTestItem = newTestItems.FirstOrDefault(x => x.Product.Name == "Test");

            Assert.IsNotNull(newTestItem);
            Assert.AreEqual(1, newTestItem.Quantity);
        }
示例#25
0
        static void Main(string[] args)
        {
            AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal);

            IProductStorage products = new ProductStorage();

            products.Add(new Product(7, "Proxying Proxies", "P. Atternborough", Category.Book));

            IEnumerable <Product> books = products
                                          .GetAll()
                                          .Where(p => p.Category == Category.Book);

            foreach (Product product in books)
            {
                Console.WriteLine(product);
            }

            Console.WriteLine("Done...");
            Console.ReadLine();
        }
示例#26
0
        public void ShoppingCartConstructorTest()
        {
            ShoppingCart testShoppingCart = null;

            try
            {
                testShoppingCart = new ShoppingCart(null, null);
                Assert.Fail();
            }
            catch (Exception e)
            {
                Assert.IsInstanceOfType(e, typeof(ArgumentException));
            }

            var discountStorage = new DiscountStorage(new List <IDiscount>());

            try
            {
                testShoppingCart = new ShoppingCart(null, discountStorage);
                Assert.Fail();
            }
            catch (Exception e)
            {
                Assert.IsInstanceOfType(e, typeof(ArgumentException));
            }

            var productStorage = new ProductStorage(new List <IProduct>());

            try
            {
                testShoppingCart = new ShoppingCart(productStorage, null);
                Assert.Fail();
            }
            catch (Exception e)
            {
                Assert.IsInstanceOfType(e, typeof(ArgumentException));
            }

            testShoppingCart = new ShoppingCart(productStorage, discountStorage);
            Assert.IsNotNull(testShoppingCart);
        }
    public IEnumerator Unload(TransportRouteElement transportRouteElement)
    {
        // Unload Products
        if (transportRouteElement == null || !(transportRouteElement.ToNode.gameObject.GetComponent <IProductReceiver>() is IProductReceiver consumer))
        {
            yield break;
        }

        foreach (TransportRouteSetting setting in transportRouteElement.RouteSettings)
        {
            bool isLoad = setting.IsLoad;
            bool isLoadedProductReceiver = consumer.ReceiverStorage(setting.ProductData) != null;
            bool hasProductLoaded        = _transporterStorage.ContainsKey(setting.ProductData);
            // if: setting is for loading, receiver not in need of the product or the truck has none of the product
            if (isLoad || !isLoadedProductReceiver || !hasProductLoaded)
            {
                continue;
            }

            Debug.Log(setting.ToString());

            ProductStorage receiverStorage = consumer.ReceiverStorage(setting.ProductData);
            ProductStorage truckStorage    = _transporterStorage[setting.ProductData];
            int            unloadAmount    = setting.Amount; // The amount that is supposed to be transferred

            // Handle actual unloading
            while (unloadAmount > 0 && truckStorage.Amount > 0 &&
                   receiverStorage.Amount < receiverStorage.MaxAmount)
            {
                unloadAmount--;
                truckStorage.Add(-TransferAmount);
                receiverStorage.Add(TransferAmount);
                yield return(new WaitForSeconds(TransferTime));
            }

            if (truckStorage.Amount == 0)
            {
                _transporterStorage.Remove(setting.ProductData);
            }
        }
    }
        /**
         * Tests to see if the Storage does not overload and throw an Exception
         */
        public IEnumerator ProductStorageTest_NotOverload()
        {
            ProductData    productData    = Resources.Load <ProductData>("Data/ProductData/Wheat");
            ProductStorage productStorage = new ProductStorage(productData, 10);

            // For test procedure
            int amountOfAddedProducts = 10;
            int transferAmount        = Random.Range(1, 5);

            for (int i = 0; i < amountOfAddedProducts; i++)
            {
                if (productStorage.Amount + transferAmount > productStorage.MaxAmount)
                {
                    Assert.Throws <OverflowException>(() => productStorage.Add(transferAmount));
                }
                else
                {
                    productStorage.Add(transferAmount);
                }
            }
            Assert.AreEqual((amountOfAddedProducts / transferAmount) * transferAmount, productStorage.Amount);
            yield return(null);
        }
        public void PrepareStorage()
        {
            var strategyFactory = CreateStrategyFactory();

            _storage = new ProductStorage
            {
                Factory         = _factory,
                StrategyFactory = strategyFactory.Object
            };
            _storage.Config = new ModuleConfig
            {
                TypeStrategies = new List <ProductTypeConfiguration>
                {
                    new ProductTypeConfiguration
                    {
                        TargetType = nameof(WatchType),
                        PluginName = nameof(WatchStrategy)
                    },
                    new GenericTypeConfiguration
                    {
                        TargetType      = nameof(WatchfaceType),
                        PropertyConfigs = new List <PropertyMapperConfig>()
                        {
                            new PropertyMapperConfig
                            {
                                PropertyName = nameof(WatchfaceType.IsDigital),
                                Column       = nameof(IGenericColumns.Integer1),
                                PluginName   = nameof(IntegerColumnMapper)
                            }
                        },
                        JsonColumn = nameof(IGenericColumns.Text8)
                    },
                    new GenericTypeConfiguration
                    {
                        TargetType      = nameof(NeedleType),
                        PropertyConfigs = new List <PropertyMapperConfig>(),
                        JsonColumn      = nameof(IGenericColumns.Text8)
                    },
                    new GenericTypeConfiguration
                    {
                        TargetType      = nameof(WatchPackageType),
                        JsonColumn      = nameof(IGenericColumns.Text8),
                        PropertyConfigs = new List <PropertyMapperConfig>()
                    }
                },
                InstanceStrategies = new List <ProductInstanceConfiguration>
                {
                    new GenericInstanceConfiguration
                    {
                        TargetType      = nameof(WatchInstance),
                        PluginName      = nameof(WatchStrategy),
                        JsonColumn      = nameof(IGenericColumns.Text8),
                        PropertyConfigs = new List <PropertyMapperConfig>
                        {
                            new PropertyMapperConfig
                            {
                                PropertyName = nameof(WatchInstance.DeliveryDate),
                                Column       = nameof(IGenericColumns.Integer1),
                                PluginName   = nameof(IntegerColumnMapper)
                            },
                            new PropertyMapperConfig
                            {
                                PropertyName = nameof(WatchInstance.TimeSet),
                                Column       = nameof(IGenericColumns.Integer2),
                                PluginName   = nameof(IntegerColumnMapper)
                            }
                        }
                    },
                    new GenericInstanceConfiguration
                    {
                        TargetType      = nameof(WatchfaceInstance),
                        PropertyConfigs = new List <PropertyMapperConfig>
                        {
                            new PropertyMapperConfig
                            {
                                PropertyName = nameof(WatchfaceInstance.Identifier),
                                Column       = nameof(IGenericColumns.Text1),
                                PluginName   = nameof(TextColumnMapper)
                            }
                        },
                        JsonColumn = nameof(IGenericColumns.Text8)
                    },
                    new ProductInstanceConfiguration()
                    {
                        TargetType = nameof(NeedleInstance),
                        PluginName = nameof(SkipArticlesStrategy)
                    },
                },
                LinkStrategies = new List <ProductLinkConfiguration>
                {
                    new ProductLinkConfiguration()
                    {
                        TargetType = nameof(WatchType),
                        PartName   = nameof(WatchType.Watchface),
                        PluginName = nameof(SimpleLinkStrategy)
                    },
                    new GenericLinkConfiguration
                    {
                        TargetType      = nameof(WatchType),
                        PartName        = nameof(WatchType.Needles),
                        JsonColumn      = nameof(IGenericColumns.Text8),
                        PropertyConfigs = new List <PropertyMapperConfig>
                        {
                            new PropertyMapperConfig
                            {
                                PropertyName = nameof(NeedlePartLink.Role),
                                PluginName   = nameof(IntegerColumnMapper),
                                Column       = nameof(IGenericColumns.Integer1)
                            }
                        }
                    },
                    new ProductLinkConfiguration()
                    {
                        TargetType = nameof(WatchPackageType),
                        PartName   = nameof(WatchPackageType.PossibleWatches),
                        PluginName = nameof(SimpleLinkStrategy)
                    },
                },
                RecipeStrategies = new List <ProductRecipeConfiguration>
                {
                    new GenericRecipeConfiguration
                    {
                        TargetType      = nameof(WatchProductRecipe),
                        JsonColumn      = nameof(IGenericColumns.Text8),
                        PropertyConfigs = new List <PropertyMapperConfig>()
                    }
                }
            };

            _storage.Start();
        }
示例#30
0
    static void Main(string[] args)
    {
        ProductStorage<IProduct> kauflandDatabase = new ProductStorage<IProduct>();

        kauflandDatabase.Add(new Product(001, "Bread", "Chicho Gosho's bakery", 1.05m));
        kauflandDatabase.Add(new Product(002, "Chokolate for cooking", "It's not from Nestle and Kraft!", 1.85m));
        kauflandDatabase.Add(new Product(003, "Tomatoes", "Baba Penka's garden", 2.45m));
        kauflandDatabase.Add(new Product(004, "Cucumbers", "Baba Penka's garden", 2.05m));
        kauflandDatabase.Add(new Product(005, "Mineral Water", "Let's say unknown brand!", 0.85m));
        kauflandDatabase.Add(new Product(006, "Nuts mix", "Grandma Ginka", 2.45m));
        kauflandDatabase.Add(new Product(007, "Teflon pan", "Unknown brand", 22.99m));
        kauflandDatabase.Add(new Product(008, "Teflon pan", "Друга марка", 20.00m));
        kauflandDatabase.Add(new Product(009, "Chokolate for cooking", "Vegan chokolates", 3.05m));
        kauflandDatabase.Add(new Product(010, "Tomatoes", "Chicho Gosho's Garden", 2.45m));
        kauflandDatabase.Add(new Product(011, "Tomatoes", "Nakov's garden", 2.05m));
        kauflandDatabase.Add(new Product(012, "Raw chokolate", "It's not from Nestle and Kraft!", 1.85m));
        kauflandDatabase.Add(new Product(013, "Small Raw Chokolate", "It's not from Nestle and Kraft!", 1.05m));
        kauflandDatabase.Add(new Product(014, "Tomatoes", "Nakov's second garden", 2.85m));
        //kauflandDatabase.Add(new Product(011, "Remove Nakov's garden tomatos", "Remove test", 2.05m));

        Console.WriteLine("---Find By Title---\n\r");
        foreach (var currentProduct in kauflandDatabase.FindProductsByTitle("Tomatoes"))
        {
            Console.WriteLine(
                    $"Id {currentProduct.Id} \n\rTitle: {currentProduct.Title} \n\rSupplier: {currentProduct.Supplier} \n\rPrice: {currentProduct.Price} \n\r");
        }

        Console.WriteLine("--- End ---\n\r");

        Console.WriteLine("---Find By Title and Price---\n\r");
        foreach (var currentProduct in kauflandDatabase.FindProductsByTitleAndPrice("Tomatoes", 2.45m))
        {
            Console.WriteLine(
                    $"Id {currentProduct.Id} \n\rTitle: {currentProduct.Title} \n\rSupplier: {currentProduct.Supplier} \n\rPrice: {currentProduct.Price} \n\r");
        }

        Console.WriteLine("--- End ---\n\r");

        Console.WriteLine("---Find By Title and Price range---\n\r");
        foreach (var currentProduct in kauflandDatabase.FindProductsByTitleAndPriceRange("Tomatoes", 2.00m, 2.45m))
        {
            Console.WriteLine(
                    $"Id {currentProduct.Id} \n\rTitle: {currentProduct.Title} \n\rSupplier: {currentProduct.Supplier} \n\rPrice: {currentProduct.Price} \n\r");
        }

        Console.WriteLine("--- End ---\n\r");

        Console.WriteLine("---Find By Supplier and Price---\n\r");
        foreach (var currentProduct in kauflandDatabase.FindProductsBySupplierAndPrice("It's not from Nestle and Kraft!", 1.85m))
        {
            Console.WriteLine(
                    $"Id {currentProduct.Id} \n\rTitle: {currentProduct.Title} \n\rSupplier: {currentProduct.Supplier} \n\rPrice: {currentProduct.Price} \n\r");
        }

        Console.WriteLine("--- End ---\n\r");

        Console.WriteLine("---Find By Supplier and Price range---\n\r");
        foreach (var currentProduct in kauflandDatabase.FindProductsBySupplierAndPriceRange("It's not from Nestle and Kraft!", 1.0m, 2.0m))
        {
            Console.WriteLine(
                    $"Id {currentProduct.Id} \n\rTitle: {currentProduct.Title} \n\rSupplier: {currentProduct.Supplier} \n\rPrice: {currentProduct.Price} \n\r");
        }

        Console.WriteLine("--- End ---\n\r");
    }
示例#31
0
 public ProductController(IConfiguration config)
 {
     _productStorage = new ProductStorage(config);
 }