Exemplo n.º 1
0
 public override void AddProduct(BaseProduct product)
 {
     try
     {
         if (product is LooseProduct)
         {
             OnIncorrectProduct?.Invoke(this, new WareHouseEventArgs(product, OnIncorrectProduct.Method.Name));
             throw new Exception($"You can't add {product.Name} in open WareHouse !");
         }
         var sku = SKUHelper.CreateSKU(product);
         if (this.ProductList.Select(p => p.SKU).Contains(sku))
         {
             this.ProductList.Find(pl => pl.SKU == sku).Quantity += product.Quantity;
         }
         else
         {
             this.ProductList.Add(product);
         }
         RaiseEvent(product);
         logger.Debug($"{product.Name} added succesfully !");
     }
     catch (Exception e)
     {
         logger.Error(e.StackTrace);
     }
 }
Exemplo n.º 2
0
 public BaseProduct(string name, string description, decimal price, float quantity)
 {
     Name        = name;
     Description = description;
     Price       = price;
     Quantity    = quantity;
     SKU         = SKUHelper.CreateSKU(this);
 }
Exemplo n.º 3
0
 public void AddProduct(BaseProduct product)
 {
     try
     {
         var sku = SKUHelper.CreateSKU(product);
         if (Catalog.Select(p => p.Key).Contains(sku))
         {
             Catalog.Where(c => c.Key == sku).FirstOrDefault().Value.Quantity += product.Quantity;
         }
         else
         {
             Catalog.Add(sku, product);
         }
         logger.Debug($"{product.Name} added succesfully !");
     }
     catch (Exception e)
     {
         logger.Error(e.Message);
     }
 }
Exemplo n.º 4
0
 public override void AddProduct(BaseProduct product)
 {
     try
     {
         var sku = SKUHelper.CreateSKU(product);
         if (this.ProductList.Select(p => p.SKU).Contains(sku))
         {
             this.ProductList.Find(f => f.SKU == sku).Quantity += product.Quantity;
         }
         else
         {
             this.ProductList.Add(product);
         }
         RaiseEvent(product);
         logger.Debug($"{product.Name} added succesfully !");
     }
     catch (Exception e)
     {
         logger.Error(e.StackTrace);
     }
 }
Exemplo n.º 5
0
 public void TransferProduct(BaseProduct product, BaseWareHouse wareHouse, float quantity)
 {
     try
     {
         var sku       = SKUHelper.CreateSKU(product);
         var productIn = this.ProductList.Find(f => f.SKU == sku);
         if (productIn.Quantity >= quantity)
         {
             productIn.Quantity += quantity;
             wareHouse.ProductList.Find(pl => pl.SKU == sku).Quantity -= quantity;
             logger.Debug($"{product.Name} transferred successfully !");
         }
         else
         {
             logger.Debug($"{product.Name} is less than available in warehouse !");
         }
     }
     catch (Exception e)
     {
         logger.Error(e.StackTrace);
     }
 }