Beispiel #1
0
        /**
         * Realiza la venta del producto a nivel de datos. Decrementa el stock del producto o lo elimina si correcponde
         */
        public void DoSell(int idProduct, int idSeller)
        {
            //Buscar en el stock, decrementar, remover del stock si queda cero, agregar a la lista de vendidos
            Product p = this.FindProductInStock(idProduct);
            Seller  s = this.FindSellerById(idSeller);

            if (p != null && s != null)
            {
                p.Stock--;
                if (p.Stock < 0)
                {
                    //this.Stock.Remove(p);
                    //RNProduct.Remove(p);
                }
                else
                {
                    RNProduct.UpdateProduct(p);
                    ProductSeller ps = new ProductSeller(idProduct, idSeller, p.Price);
                    //this.Sold.Add(ps);
                    RNProductSeller.AddProductSeller(ps);
                }
            }
        }
Beispiel #2
0
        /**
         * Agrega el producto en la base de productos. En caso que ya este incrementa el stock
         */
        public void AddToStock(Product newProduct)
        {
            //Si el producto ya existe solo debe incrementar el stock y actualizar los datos del producto.
            //Primero se debe hacer una busqueda para validar si el producto ya existe en la base
            Product existingProduct = this.FindProductInStock(newProduct.IdProduct);

            if (existingProduct != null)
            {
                existingProduct.Name     = newProduct.Name;
                existingProduct.Stock   += newProduct.Stock;
                existingProduct.Price    = newProduct.Price;
                existingProduct.Active   = newProduct.Active;
                existingProduct.IdSeller = newProduct.IdSeller;
                //existingProduct.Seller = DBService.GetInstance().FindSellerById(newProduct.Seller.IdSeller);
                //existingProduct.Seller = RNSeller.SearchSeller(newProduct.Seller.IdSeller);
                RNProduct.UpdateProduct(existingProduct);
            }
            else
            {
                // this.Stock.Add(newProduct);
                RNProduct.AddProduct(newProduct);
            }
        }
Beispiel #3
0
 /*
  * Cambia el estado del producto a Activado o Desactivado
  */
 internal void ChangeProductStatus(Product product)
 {
     product.Active = !product.Active;
     RNProduct.UpdateProduct(product);
 }