private void ReplenishInventory()
        {
            //Todo- add a multiple replenishing options
            Console.WriteLine("View out of stock items and start replenishing?");
            string option = _validate.ValidateValidCommand("\tEnter [Y] to continue\n\tEnter [N] to skip");
            string productCode;

            if (option.ToLower() == "y")
            {
                viewOutofStockItems();
                productCode = _validate.ValidateEmptyInput("Select a product from above table by Product Id");
            }
            else
            {
                productCode = _validate.ValidateEmptyInput("Enter a Product Id");
            }
            int     id          = Int32.Parse(productCode);
            Product product     = _productBL.GetProductById(id);
            int     newQuantity = _validate.ValidateQuantity("Enter quantity for this item");
            Item    inventory   = _inventoryBL.GetInventory(product);

            _inventoryBL.UpdateInventory(inventory, newQuantity);

            Console.WriteLine($"{newQuantity} for {product.Name} is updated.");
            Console.WriteLine("==================================================");
        }
Exemplo n.º 2
0
        public ActionResult SaveOrder(OrderIndexVM orderIndexVM)
        {
            //saves to the table
            var order = new Order
            {
                CustomerID = orderIndexVM.CustomerID,
                LocationID = orderIndexVM.LocationID,
                Total      = GetTotal(orderIndexVM.DrinkOrders)
            };

            order = _orderBL.AddOrder(order);
            foreach (var item in orderIndexVM.DrinkOrders)
            {
                if (item.Quantity > 0)
                {
                    var drinkOrder = new DrinkOrder
                    {
                        DrinkId  = item.DrinkId,
                        OrderId  = order.OrderID,
                        Quantity = item.Quantity
                    };
                    _orderBL.AddDrinkOrder(drinkOrder);
                }
                var inventory = _inventoryBL.GetInventoryByLocationIDAndDrinkID(order.LocationID, item.DrinkId);
                if (inventory != null)
                {
                    inventory.Quantity -= item.Quantity;
                    _inventoryBL.UpdateInventory(inventory);
                }
            }



            return(RedirectToAction("Index", "Home"));
        }
Exemplo n.º 3
0
        private decimal AddItem(Order order)
        {
            string productCode = _validate.ValidateEmptyInput("Select a Bubble Tea from above table by Product Id");

            int id = Int32.Parse(productCode);

            int     quantity = _validate.ValidateQuantity("Enter quantity for this item");
            Product product  = _productBL.GetProductById(id);

            //To-Do check enough inventory
            Item inventory = _inventoryBL.GetInventory(product);

            _orderBL.AddOrderItem(order, product, new Item(quantity));

            //To-Do update inventory
            int newQuantity = inventory.Quantity - quantity;

            _inventoryBL.UpdateInventory(inventory, newQuantity);

            Console.WriteLine($"{quantity} {product.Name} is added");
            return //product.Price * quantity;

                   (_orderBL.GetTotal(product.Id, quantity));
        }
Exemplo n.º 4
0
        public void GetSearchedInventoriesForUpdate(string searchTerm)
        {
            Inventory        foundInventory = new Inventory();
            int              tracker        = 0;
            LineSeparator    line           = new LineSeparator();
            List <Inventory> inventoryList  = _inventoryBL.GetInventory();

            foreach (Inventory inventory in inventoryList)
            {
                if (inventory.Product.ProductName.Contains(searchTerm) || inventory.InventoryName.Contains(searchTerm) || inventory.Location.LocationName.Contains(searchTerm) || searchTerm == inventory.InventoryID.ToString())
                {
                    line.LineSeparate();
                    Console.WriteLine(inventory);
                    tracker++;
                    //for the first found inventory, store in our foundinventory object, but don't do it again
                    if (tracker == 1)
                    {
                        foundInventory = inventory;
                    }
                }
            }


            if (tracker == 0)
            {
                line.LineSeparate();
                Console.WriteLine("No results found! Please double-check customer name spelling. \nReminder: This search system is Case Sensitive :)");
            }
            //if the tracker only happened once, that means one customer with the matching value was found, so we pass that customer reference
            //back out to our manager system :)
            if (tracker == 1)
            {
                line.LineSeparate();
                Console.WriteLine("We have found one inventory from your search. Please see the details displayed above.");
                Console.WriteLine("Would you like to edit this inventory?");
                Console.WriteLine("[0] Yes");
                Console.WriteLine("[1] No");
                switch (Console.ReadLine())
                {
                case "0":
                    Console.WriteLine($"Please enter the updated product quantity for the {foundInventory.InventoryName} inventory: ");
                    foundInventory.ProductQuantity = Int32.Parse(Console.ReadLine());
                    //we need to check if the specified inventory has said product in stock for the amount desired


                    Console.WriteLine($"updated inventory quantity: {foundInventory.ProductQuantity}");



                    _inventoryBL.UpdateInventory(foundInventory);
                    Console.WriteLine("Inventory updated successfully!");
                    Console.WriteLine("Press enter to continue.");
                    Console.ReadLine();
                    Console.Clear();



                    break;

                case "1":
                    Console.WriteLine("Okay, please search again to find a different inventory. \nPress enter to continue.");
                    Console.ReadLine();
                    Console.Clear();
                    break;

                default:
                    Console.WriteLine("This is not a valid menu option!");
                    break;
                }
            }

            line.LineSeparate();
        }
Exemplo n.º 5
0
        public void GetFilteredProductsForProcessing(string searchTerm, int cartID, List <Inventory> inventories, Location location)
        {
            //keeps track of the product if only 1 product is found
            Product foundProduct = new Product();

            //tracks how many products have been found given the search
            int tracker = 0;

            LineSeparator line = new LineSeparator();
            //retrieves a list of all products
            List <Product> productList = _productBL.GetProduct();
            //new list intended to filter products down to only those that exist in inventories for our location
            List <Product> filteredByInventoryProducts = new List <Product>();
            //our list of filtered inventories
            List <Inventory> filteredByLocationInventories = new List <Inventory>();

            //filter inventories to only those at our location
            //if the location ID of this inventory matches our stored location ID, then add it to the list of filtered locations
            foreach (Inventory i in inventories)
            {
                if (i.Location.LocationID == location.LocationID)
                {
                    filteredByLocationInventories.Add(i);
                }
            }

            //filter products to display only those that exist in one of the found inventories
            //for each product that we've retrieved, make sure that the product ID matches a product ID stored in an inventory
            foreach (Product p in productList)
            {
                foreach (Inventory i in filteredByLocationInventories)
                {
                    if (i.ProductID == p.ProductID)
                    {
                        filteredByInventoryProducts.Add(p);
                    }
                }
            }


            foreach (Product product in filteredByInventoryProducts)
            {
                if (product.ProductName.Contains(searchTerm) || product.Manufacturer.Contains(searchTerm) || product.ProductID.ToString().Contains(searchTerm))
                {
                    line.LineSeparate();
                    Console.WriteLine(product);
                    tracker++;
                    //for the first found customer, store in our foundcustomer object, but don't do it again
                    if (tracker == 1)
                    {
                        foundProduct.ProductID          = product.ProductID;
                        foundProduct.ProductName        = product.ProductName;
                        foundProduct.ProductDescription = product.ProductDescription;
                        foundProduct.Manufacturer       = product.Manufacturer;
                        foundProduct.ProductPrice       = product.ProductPrice;
                    }
                }
            }

            if (tracker == 0)
            {
                line.LineSeparate();
                Console.WriteLine("No results found! Please double-check customer name spelling. \nReminder: This search system is Case Sensitive :)");
            }
            //if the tracker only happened once, that means one customer with the matching value was found, so we pass that customer reference
            //back out to our manager system :)
            if (tracker == 1)
            {
                line.LineSeparate();
                Console.WriteLine("We have found one product from your search. Please see the details displayed above.");
                Console.WriteLine("Would you like to add this product to your cart?");
                Console.WriteLine("[0] Yes");
                Console.WriteLine("[1] No");
                switch (Console.ReadLine())
                {
                case "0":
                    CartProducts cartProduct = new CartProducts();

                    List <Inventory> inventoriesFiltered = new List <Inventory>();
                    //we need to check if the specified inventory has said product in stock for the amount desired
                    foreach (Inventory i in inventories)
                    {
                        if (i.ProductID == foundProduct.ProductID && i.InventoryLocation == location.LocationID)
                        {
                            inventoriesFiltered.Add(i);
                        }
                    }

                    Inventory realInventory = inventoriesFiltered[0];
                    Console.WriteLine($"We currently have {realInventory.ProductQuantity} of these in stock at the {location.LocationName} location!");
                    Console.WriteLine("Please enter how many you would like to order: ");
                    cartProduct.ProductCount = Int32.Parse(Console.ReadLine());

                    if (realInventory.ProductQuantity < cartProduct.ProductCount)
                    {
                        Console.WriteLine($"Sorry, we only have {realInventory.ProductQuantity} left in stock at {location.LocationName}.\nPlease enter a lower quantity");
                        Console.WriteLine("Press enter to continue.");
                        break;
                    }
                    if (cartProduct.ProductCount <= 0)
                    {
                        Console.WriteLine("Sorry, you've entered an invalid value. Please try again");
                        Console.WriteLine("Press enter to continue.");
                        Console.ReadLine();
                        break;
                    }

                    cartProduct.CartID            = cartID;
                    cartProduct.ProductID         = foundProduct.ProductID;
                    realInventory.ProductQuantity = realInventory.ProductQuantity - cartProduct.ProductCount.Value;


                    Console.WriteLine($"current inventory value: {realInventory.ProductQuantity}");



                    _cartProductsBL.AddCartProduct(cartProduct);
                    _inventoryBL.UpdateInventory(realInventory);
                    Log.Information($"product added to cart {cartProduct.ProductID}");
                    Console.WriteLine("Product added to cart successfully!");
                    Console.WriteLine("Press enter to continue.");
                    Console.ReadLine();



                    break;

                case "1":
                    Console.WriteLine("Okay, please search again to find a different product. \nPress enter to continue.");
                    Console.ReadLine();

                    break;

                default:
                    Console.WriteLine("This is not a valid menu option!");
                    break;
                }
            }

            line.LineSeparate();
        }
Exemplo n.º 6
0
        public void ShopInventory(int locId, int custId)
        {
            bool    stillShopping = true;
            decimal runningTotal  = 0.00m;

            do
            {
                Console.WriteLine("Which product you would like to purchase?");
                foreach (var item in _locationBL.GetLocations())
                {
                    if (item.Id == locId)
                    {
                        foreach (var product in _productBL.GetProducts())
                        {
                            if (_inventoryBL.GetInventoryById(product.ProductID, locId) == null)
                            {
                                continue;
                            }
                            else
                            {
                                Console.WriteLine($"[{product.ProductID}] {product.ProductName} {product.ProductPrice}/Pint \t{_inventoryBL.GetQuantity(product.ProductID, locId)} in stock");
                            }
                        }
                    }
                }
                Console.WriteLine("Enter a number:");
                int userInputKind = int.Parse(Console.ReadLine());

                Console.WriteLine("How many pints would you like?");
                int userInputPints = int.Parse(Console.ReadLine());

                if (userInputPints <= _inventoryBL.GetQuantity(userInputKind, locId))
                {
                    Inventory updatedInventory = new Inventory();
                    updatedInventory.Quantity = _inventoryBL.GetQuantity(userInputKind, locId) - userInputPints;
                    _inventoryBL.UpdateInventory(_inventoryBL.GetInventoryById(userInputKind, locId), updatedInventory);
                    runningTotal += (_productBL.GetProductPrice(userInputKind) * (decimal)userInputPints);
                }
                else
                {
                    Console.WriteLine("Sorry we do not have that in stock.");
                }

                bool isCustomerStillShopping = true;
                do
                {
                    Console.WriteLine("Would you like to keep shopping?");
                    Console.WriteLine("[0] Yes, browse more products.");
                    Console.WriteLine("[1] No, Checkout.");

                    string inputKeepShopping = Console.ReadLine();

                    switch (inputKeepShopping)
                    {
                    case "0":
                        isCustomerStillShopping = false;
                        break;

                    case "1":
                        CheckoutItems(runningTotal, locId, custId);
                        break;

                    default:
                        Console.WriteLine("Not part of menu! Please try again.");
                        break;
                    }
                } while (isCustomerStillShopping);
            } while (stillShopping);
        }