public int OrderFromSupplier(int missingStock, int?id)
        {
            PackageStock packageStock  = db.PackageStocks.Find(id);
            int          packageNeeded = missingStock + ReorderingLevel + packageStock.Quantity;

            return(packageNeeded);
        }
        public void UpdateStock(int?id)
        {
            PackageStock packageStock = db.PackageStocks.Find(id);

            if (packageStock != null)
            {
                if (packageStock.Quantity <= MinimumStock)
                {
                    int missingStock = MinimumStock - packageStock.Quantity;

                    packageStock.Quantity = OrderFromSupplier(missingStock, id);
                }
            }
        }
        public int SendToProduction(int orderAmount, int?id)
        {
            PackageStock packageStock = db.PackageStocks.Find(id);

            if (orderAmount > packageStock.Quantity)
            {
                UpdateStock(id);
                return(packageStock.Quantity);
            }
            else
            {
                packageStock.Quantity = packageStock.Quantity - orderAmount;
                //   db.SaveChanges();
                if (packageStock.Quantity <= MinimumStock)
                {
                    UpdateStock(id);
                }
                return(packageStock.Quantity);
            }
        }