public int OrderFromSupplier(int missingStock, int?id) { RawMaterialStock rawMaterialStock = db.RawMaterialStocks.Find(id); int rawMaterialNeeded = missingStock + ReorderingLevel + rawMaterialStock.Quantity; return(rawMaterialNeeded); }
public void UpdateStock(int?id) { RawMaterialStock rawMaterialStock = db.RawMaterialStocks.Find(id); if (rawMaterialStock != null) { if (rawMaterialStock.Quantity <= MinimumStock) { int missingStock = MinimumStock - rawMaterialStock.Quantity; rawMaterialStock.Quantity = OrderFromSupplier(missingStock, id); } } }
public int SendToProduction(int orderAmount, int?id) { RawMaterialStock rawMaterialStock = db.RawMaterialStocks.Find(id); if (orderAmount > rawMaterialStock.Quantity) { int sentQuantity = rawMaterialStock.Quantity; UpdateStock(id); return(sentQuantity); } else { rawMaterialStock.Quantity = rawMaterialStock.Quantity - orderAmount; if (rawMaterialStock.Quantity <= MinimumStock) { UpdateStock(id); } return(rawMaterialStock.Quantity); } }