Esempio n. 1
0
        public void AddStoreHouseProduct(StorehouseProduct prod)
        {
            SortedDictionary <string, List <StorehouseProduct> > dictGroups;
            List <StorehouseProduct> listProducts;

            if (GetGroupsFromCategory(prod.ProductCategory) == null)
            {
                listProducts = new List <StorehouseProduct>();
                listProducts.Add(prod);
                dictGroups = new SortedDictionary <string, List <StorehouseProduct> >();
                dictGroups.Add(prod.ProductGroup, listProducts);
                _productStorage.Add(prod.ProductCategory, dictGroups);
            }
            else
            {
                dictGroups = GetGroupsFromCategory(prod.ProductCategory);
                if (GetListProductsFromGroup(dictGroups, prod.ProductGroup) == null)
                {
                    listProducts = new List <StorehouseProduct>();
                    listProducts.Add(prod);
                    dictGroups.Add(prod.ProductGroup, listProducts);
                }
                else
                {
                    listProducts = GetListProductsFromGroup(dictGroups, prod.ProductGroup);
                    listProducts.Add(prod);
                }
            }

            AddProductInCatalog(prod);
        }
Esempio n. 2
0
        private void AddProductInCatalog(StorehouseProduct prod)
        {
            SortedDictionary <string, List <ProductCharacteristic> > dictGroups;
            List <ProductCharacteristic> listCharacteristics;

            if (GetCatalogGroupsFromCategory(prod.ProductCategory) == null)
            {
                listCharacteristics = new List <ProductCharacteristic>();
                listCharacteristics.Add(prod.GetProductCharacteristic());
                dictGroups = new SortedDictionary <string, List <ProductCharacteristic> >();
                dictGroups.Add(prod.ProductGroup, listCharacteristics);
                _productCatalog.Add(prod.ProductCategory, dictGroups);
            }
            else
            {
                dictGroups = GetCatalogGroupsFromCategory(prod.ProductCategory);
                if (GetCatalogListProductsFromGroup(dictGroups, prod.ProductGroup) == null)
                {
                    listCharacteristics = new List <ProductCharacteristic>();
                    listCharacteristics.Add(prod.GetProductCharacteristic());
                    dictGroups.Add(prod.ProductGroup, listCharacteristics);
                }
                else
                {
                    listCharacteristics = GetCatalogListProductsFromGroup(dictGroups, prod.ProductGroup);
                    listCharacteristics.Add(prod.GetProductCharacteristic());
                }
            }
        }
Esempio n. 3
0
        public ProductFromLot GetProduct(int productId, int numberOfProduct)
        {
            StorehouseProduct            baseProd = FindStorehouseProductById(productId);
            IServiceForStorehouseProduct service  = _kernel.Get <IServiceForStorehouseProduct>();

            service.SetStorehouseProduct(baseProd);
            ProductFromLot prod = service.GetProductFromLot(numberOfProduct);

            service.UpdateProductCharacteristic();
            return(prod);
        }
 public void SetStorehouseProduct(StorehouseProduct product)
 {
     if (product != null)
     {
         this._product = product;
     }
     else
     {
         throw new NullReferenceException();
     }
 }
Esempio n. 5
0
        public override object Clone()
        {
            StorehouseProduct clone = new StorehouseProduct();

            clone.ExpirationDate       = this.ExpirationDate;
            clone.Measure              = (Measure)this.Measure.Clone();
            clone.Price                = this.Price;
            clone.ProduceCountry       = (string)this.ProduceCountry.Clone();
            clone.ProductCategory      = (string)this.ProductCategory.Clone();
            clone.ProductGroup         = (string)this.ProductGroup.Clone();
            clone.ProductId            = this.ProductId;
            clone.ProductName          = (string)this.ProductName.Clone();
            clone.TotalQuantityProduct = this.TotalQuantityProduct;
            clone._characteristic      = (ProductCharacteristic)this._characteristic.Clone();

            return(clone);
        }
Esempio n. 6
0
        public void AddProduct(ProductFromLot prod)
        {
            bool contains = _repository.ContainsProduct(prod);

            if (contains)
            {
                _repository.AddProductFromLot(prod);
            }
            else
            {
                StorehouseProduct storehouseProduct = new StorehouseProduct(prod);
                storehouseProduct.ProductId = GetProductId();
                IServiceForStorehouseProduct service = _kernel.Get <IServiceForStorehouseProduct>();
                service.SetStorehouseProduct(storehouseProduct);
                service.UpdateProductCharacteristic();
                _repository.AddStoreHouseProduct(storehouseProduct);
            }
        }