private void ProductPriceAtt(ProductIncomeDetail item) { ProductBLL productBLL = new ProductBLL(); Storage storage = new Storage(); storage.ProductsID = item.IDProduct; double qtdProductsStorage = Convert.ToDouble(storageDAO.GetQuantityByIDProducts(item).Data); double productPrice = Convert.ToDouble(productBLL.GetPriceByID(item.IDProduct)); double qtdProductsEntry = item.Quantity; double products = ((qtdProductsStorage * productPrice) + (qtdProductsEntry * item.Price)) / qtdProductsStorage + qtdProductsEntry; productBLL.UpdatePrice(item.IDProduct, products); }
public SingleResponse <Storage> AddProduct(ProductIncomeDetail item) { SingleResponse <Storage> singleResponse = new SingleResponse <Storage>(); Storage storage = new Storage(); storage.ProductsID = item.IDProduct; StorageDAO storageDAO = new StorageDAO(); if (storageDAO.GetQuantityByIDProducts(item).Quantity == 0) { item.Quantity = storageDAO.GetQuantityByIDProducts(item).Quantity; storage.Quantity = item.Quantity; Update(storage); } else if (storageDAO.GetQuantityByIDProducts(item).Quantity > 0) { ProductPriceAtt(item); item.Quantity += storageDAO.GetQuantityByIDProducts(item).Quantity; storage.Quantity = item.Quantity; Update(storage); } return(singleResponse); }