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

            return(packageNeeded);
        }
Ejemplo n.º 2
0
        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);
                }
            }
        }
Ejemplo n.º 3
0
        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);
            }
        }