public ProductStock SendProductStock(int orderAmount, string id)
        {
            ProductStock productStock = db.ProductStocks.Single(p => p.ProductStockID == id);


            if (orderAmount >= productStock.AvailableQuantity)
            {
                productStock.ActualQuantity -= productStock.AvailableQuantity;

                orderAmount = productStock.AvailableQuantity;
                //// the whole available quantity is being sent if the order amount is larger
                productStock.AvailableQuantity = 0;

                // update the stock because it is low
                //UpdateStock(productStock);

                // return this for warehouse View
                return(productStock);
            }
            else
            {
                productStock.AvailableQuantity = productStock.AvailableQuantity - orderAmount;
                productStock.ActualQuantity    = productStock.ActualQuantity - orderAmount;

                //if (productStock.AvailableQuantity <= MinimumStock)
                //{
                //    UpdateStock(productStock);
                //}
                return(productStock);
            }
        }
Beispiel #2
0
        public ProductStock SendProductStock(int orderAmount, string id)
        {
            ProductStock productStock = _context.ProductStocks.Single(p => p.ProductStockID == id);


            if (orderAmount >= productStock.AvailableQuantity)
            {
                productStock.ActualQuantity -= productStock.AvailableQuantity;

                orderAmount = productStock.AvailableQuantity;
                //// the whole available quantity is being sent if the order amount is larger
                productStock.AvailableQuantity = 0;


                // return this for warehouse View
                return(productStock);
            }
            else
            {
                productStock.AvailableQuantity = productStock.AvailableQuantity - orderAmount;
                productStock.ActualQuantity    = productStock.ActualQuantity - orderAmount;

                return(productStock);
            }
        }