Beispiel #1
0
        //displays a border with the vending options inside it
        private void AsciiArt()
        {
            getProductList    = new GetProductList(fileRepo);
            updateVendingRepo = new UpdateVendingRepo(fileRepo);
            Dictionary <string, VendingItem> products = getProductList.GetProducts();
            string a1ItemName = MessageProductName(products, "A1");
            string a2ItemName = MessageProductName(products, "A2");
            string a3ItemName = MessageProductName(products, "A3");
            string b1ItemName = MessageProductName(products, "B1");
            string b2ItemName = MessageProductName(products, "B2");
            string b3ItemName = MessageProductName(products, "B3");
            string a1Price    = MessageProductPrice(products, "A1");
            string a2Price    = MessageProductPrice(products, "A2");
            string a3Price    = MessageProductPrice(products, "A3");
            string b1Price    = MessageProductPrice(products, "B1");
            string b2Price    = MessageProductPrice(products, "B2");
            string b3Price    = MessageProductPrice(products, "B3");

            Console.WriteLine("(_}{_}{_}{_}{_}{_}{_}{_}{_}{_}{_}{_}{_}{_}{_}{_)");
            Console.Write("##");
            Console.ForegroundColor = ConsoleColor.Cyan;
            Console.WriteLine("      {0,-10}{1,-10}{2,-10}", "A1", "A2", "A3");
            Console.ResetColor();
            Console.WriteLine("##   {0,-12}{1,-10}{2}", a1ItemName, a2ItemName, a3ItemName);
            Console.WriteLine("##   {0,-11}{1,-10}{2}", a1Price, a2Price, a3Price);
            Console.WriteLine("##");
            Console.WriteLine("##");
            Console.Write("##");
            Console.ForegroundColor = ConsoleColor.Cyan;
            Console.WriteLine("      {0,-10}{1,-10}{2,-10}", "B1", "B2", "B3");
            Console.ResetColor();
            Console.WriteLine("##    {0,-11}{1,-10}{2}", b1ItemName, b2ItemName, b3ItemName);
            Console.WriteLine("##   {0,-11}{1,-11}{2}", b1Price, b2Price, b3Price);
            Console.WriteLine("(_}{_}{_}{_}{_}{_}{_}{_}{_}{_}{_}{_}{_}{_}{_}{_)");
        }
Beispiel #2
0
        public bool UpdateProduct(Customer activeCustomer)
        {
            Console.Clear();

            Console.WriteLine("Type a product id and press enter...");
            // Generate Product Menu //
            var customerProduct = new GetProductList();
            var products        = customerProduct.GetProducts(activeCustomer.CustomerID);

            foreach (var product in products)
            {
                Console.WriteLine($"{product.ProductID}. {product.Name}: {product.Price}");
            }
            Console.WriteLine("\nPress [0] to return to the main menu");

            // Read Input and Remove Product by ID //
            var id = int.Parse(Console.ReadLine());

            if (id == 0)
            {
                return(true);
            }

            if (ChangeProduct.ProductUpdater(id))
            {
                Console.WriteLine("Product updated. Press Enter to Continue");
                Console.ReadLine();
                return(true);
            }
            else
            {
                Console.WriteLine("Product did not update");
                return(false);
            }
        }
Beispiel #3
0
        public bool DeleteProduct(Customer activeCustomer)
        {
            Console.Clear();
            Console.WriteLine("1: Remove Product");
            Console.WriteLine("2: Return to Main Menu");
            var productSubSelection = Console.ReadKey();
            var remove = true;

            while (remove)
            {
                switch (productSubSelection.KeyChar)
                {
                case '0':
                    remove = false;
                    break;

                case '1':
                    Console.Clear();
                    Console.WriteLine("Type a product id and press enter...");
                    // Generate Product Menu //
                    var customerProducts = new GetProductList();
                    var ProductData      = customerProducts.GetProducts(activeCustomer.CustomerID);

                    foreach (var product in ProductData)
                    {
                        Console.WriteLine($"{product.ProductID}. {product.Name}: {product.Price}");
                    }
                    Console.WriteLine("\nPress [0] to return to the main menu");

                    // Read Input and Remove Product by ID //
                    var selection     = Console.ReadLine();
                    var productDelete = new RemoveProduct().DeleteProduct(int.Parse(selection));
                    if (int.Parse(selection) == 0)
                    {
                        remove = false;
                    }
                    else if (productDelete)
                    {
                        Console.WriteLine("Product deleted press enter to relaod list");
                        Console.ReadKey();
                    }
                    else
                    {
                        Console.WriteLine("Product not deleted or does not exist");
                    }
                    //Console.ReadKey();
                    break;

                case '2':
                    remove = false;
                    break;
                }
            }
            return(true);
        }
Beispiel #4
0
        public void DisplayMenu()
        {
            getProductList    = new GetProductList(fileRepo);
            updateVendingRepo = new UpdateVendingRepo(fileRepo);

            AsciiArt();
            Console.WriteLine();
            new CalculateChange(ConsoleIO.ReadDecimailInRange("How Much money do you want to put into the vending machine: ", 0, 100));

            int selection = 0;

            do
            {
                Console.Clear();
                Dictionary <string, VendingItem> products = getProductList.GetProducts();
                AsciiArt();

                Console.WriteLine();

                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine($"Current Money: ${CalculateChange.Money}");
                Console.ResetColor();
                selection = ConsoleIO.SelectFromMenu();
                switch (selection)
                {
                case 1:
                    CalculateChange.AddMoney();
                    break;

                case 2:
                    Console.Clear();
                    AsciiArt();
                    Console.WriteLine();
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.WriteLine($"Current Money: ${CalculateChange.Money}");
                    Console.ResetColor();
                    updateVendingRepo.UpdateVending();
                    break;
                }
            } while (selection > 0 && selection < 3);

            Console.Clear();
            Console.WriteLine("GOODBYE!");
            Console.ReadKey();
        }