Exemple #1
0
        /// <summary>
        /// Calls DatabaseControl to get a list of Locations, Displays Locations
        /// Calls InputControl to get users choice of location or returing to Customer Homepage
        /// </summary>
        /// <returns>NextPage, CurrentLocation</returns>
        internal static (string, Location) DisplayStoreLocations()
        {
            Location CurrentLocation;
            string   NextPage = "STORE HOMEPAGE";

            List <Location> Locations = DatabaseControl.GetAllLocations();

            Console.WriteLine("----------------------STORES---------------------------");
            int NumStores = 1;

            foreach (Location l in Locations)
            {
                Console.WriteLine($"\n\nStore #{NumStores}" +
                                  $"\n--------------{l.Name}--------------" +
                                  $"\n{l.AddressNum} {l.AddressStreet} " +
                                  $"\n{l.AddressCity}, {l.AddressState} {l.AddressZipCode}");
                NumStores++;
            }
            Console.WriteLine("\nWhich store would you like to visit?" +
                              "\nEnter the store number to proceed" +
                              "\nEnter 0 to go back to the Customer Homepage");

            int choice = InputControl.VerifyListChoiceStartingAt0(NumStores);

            if (choice == -1)
            {
                NextPage        = "CUSTOMER HOMEPAGE";
                CurrentLocation = null;
            }
            else
            {
                CurrentLocation = Locations[choice];
            }
            return(NextPage, CurrentLocation);
        }
Exemple #2
0
        /// <summary>
        /// Calls DatabaseControl to GetAllProducts and Display those of the Type
        /// the user selected.
        /// Calls InputControl to get the users selection and returns directions for
        /// the NextPage and the Product the user chose (ProductToBuy = null if user chose to go back)
        /// </summary>
        /// <param name="Type">NextPage, ProductToBuy</param>
        /// <returns></returns>
        internal static (string, Product) DisplayProductPage(string Type)
        {
            string  NextPage     = "GO BACK";
            Product ProductToBuy = null;

            int NumProducts = 1;

            List <Product> Products       = DatabaseControl.GetAllProducts();
            List <Product> ProductsOfType = new List <Product>();

            foreach (Product p in Products)
            {
                if (p.Type == Type)
                {
                    Console.WriteLine($"\nProduct {NumProducts}:");
                    Console.WriteLine($"Name: {p.Name}");
                    Console.WriteLine($"Price: {p.Price}");
                    Console.WriteLine($"Description: {p.Description}");
                    ProductsOfType.Add(p);
                    NumProducts++;
                }
            }
            NumProducts--;

            Console.WriteLine("\nEnter a number to add a product to your cart or enter 0 to go back");
            int choice = InputControl.VerifyListChoiceStartingAt0(NumProducts);

            if (choice != -1)
            {
                ProductToBuy = ProductsOfType[choice];
                NextPage     = "LOCATIONS WITH PRODUCT";
            }
            return(NextPage, ProductToBuy);
        }
Exemple #3
0
        internal static int DisplayQuantityPrompt(Product ProductToBuy, Location CurrentLocation)
        {
            int InStock = DatabaseControl.FindNumInStockAtLocation(ProductToBuy, CurrentLocation);

            Console.WriteLine($"\n{ProductToBuy.Name}");
            Console.WriteLine($"In stock: {InStock}");
            Console.WriteLine("\nEnter Quantity:");
            return(InputControl.VerifyListChoiceStartingAt1(InStock) + 1);
        }
Exemple #4
0
        internal static string DisplayConfirmOrder(List <Product> ShoppingCart, Billing BillingInfo, Customer CurrentCustomer, Location CurrrentLocation, List <int> Quantities)
        {
            string NextPage = DisplayShoppingCart(false, ShoppingCart, Quantities);

            if (NextPage == "CHECKOUT")
            {
                Console.WriteLine("\n------CONFIRMING-YOUR-ORDER-------------");
                DatabaseControl.PlaceOrder(ShoppingCart, BillingInfo, CurrentCustomer, CurrrentLocation, Quantities);
                Thread.Sleep(1000);
                Console.WriteLine("\n---------------YOUR-ORDER-HAS-BEEN-CONFIRMED---------------");
                Console.WriteLine("\n---------ROUTING-YOU-BACK-TO-THE-STORES-HOMEPAGE-----------");
                NextPage = "CUSTOMER HOMEPAGE";
            }
            return(NextPage);
        }
Exemple #5
0
        internal static void DisplayCustomers()
        {
            List <Customer> Customers = DatabaseControl.GetAllCustomers();
            int             NumC      = 1;

            Console.WriteLine("\n-----------------SHOWING-CUSTOMERS----------------");
            foreach (Customer c in Customers)
            {
                Console.WriteLine($"\nCustomer {NumC}:");
                Console.WriteLine($"First Name: {c.FirstName}");
                Console.WriteLine($"Last Name: {c.LastName}");
                NumC++;
            }
            Console.WriteLine("\nHit any key to go back.");
            Console.ReadLine();
        }
Exemple #6
0
        /// <summary>
        /// Calls DatabaseControl to get a list of all Products of a specific type from a specific location
        /// Displays these products, Calls InputControl to get the user's choice
        /// If a product is selected, it is added to the Shopping Cart, and DisplayPostProductSelectionAtLocation() is called
        /// and returns the NextPage that the user chooses, which this method then returns to the while loop in Program.cs
        /// </summary>
        /// <param name="Type"></param>
        /// <param name="CurrentLocation"></param>
        /// <param name="ShoppingCart"></param>
        /// <returns>NextPage, ShoppingCart</returns>
        internal static (string, List <Product>, List <int>) DisplayProductAtStore(string Type, Location CurrentLocation, List <Product> ShoppingCart, List <int> Quantities)
        {
            String         NextPage;
            List <Product> ProductsOfType = DatabaseControl.FindProductsOfTypeFromStore(Type, CurrentLocation);

            if (ProductsOfType.Count > 0)
            {
                int NumStores = 1;
                foreach (Product p in ProductsOfType.ToList())
                {
                    Console.WriteLine($"\nProduct {NumStores}:");
                    Console.WriteLine($"Name: {p.Name}");
                    Console.WriteLine($"Price: {p.Price}");
                    Console.WriteLine($"Description: {p.Description}");
                    ProductsOfType.Add(p);
                    NumStores++;
                }
                NumStores--;
                Console.WriteLine("\nEnter a number to add a product to your cart or enter 0 to go back");

                int choice = InputControl.VerifyListChoiceStartingAt0(NumStores);

                if (choice == -1)
                {
                    NextPage = "GO BACK";
                }
                else
                {
                    Product ProductToBuy = ProductsOfType[choice];
                    int     Quantity     = DisplayQuantityPrompt(ProductToBuy, CurrentLocation);
                    ShoppingCart.Add(ProductToBuy);
                    Quantities.Add(Quantity);
                    NextPage = DisplayPostProductSelectionAtLocation(ProductToBuy);
                }
            }
            else
            {
                Console.WriteLine("Oops! We are all out of those!");
                Thread.Sleep(1000);
                Console.WriteLine("\n-----ROUTING-YOU-BACK-TO-THE-PRODUCTS-HOMEPAGE-----");
                Thread.Sleep(1250);
                NextPage = "VIEW PRODUCTS AT STORE";
            }
            return(NextPage, ShoppingCart, Quantities);
        }
Exemple #7
0
        internal static string DisplayCheckoutHome(List <Product> ShoppingCart, Customer CurrentCustomer, Location CurrentLocation, List <int> Quantities)
        {
            String  NextPage   = DisplayShoppingCart(false, ShoppingCart, Quantities);
            Billing CardChosen = null;

            if (NextPage == "CHECKOUT")
            {
                int choice = DisplayCheckoutPrompt();
                if (choice == 1)
                {
                    Billing CardInfoEntered = DisplayGetBillingInformation();
                    DatabaseControl.AddNewCardInformationToUser(CardInfoEntered, CurrentCustomer);
                    NextPage = DisplayConfirmOrder(ShoppingCart, CardInfoEntered, CurrentCustomer, CurrentLocation, Quantities);
                }
                else if (choice == 2)
                {
                    List <Billing> CardOptions = DatabaseControl.GetCardsOnFileForCustomer(CurrentCustomer);
                    if (CardOptions.Count() == 0)
                    {
                        Console.WriteLine("\nYou do not have a card saved on file!");
                        Console.WriteLine("\n---------ROUTING-YOU-BACK-TO-CHECKOUT----------");
                        Thread.Sleep(1000);
                        NextPage = "CHECKOUT";
                    }
                    else
                    {
                        int NumCards = DisplayCardsOnFile(CardOptions);
                        Console.WriteLine("\nEnter a number to choose a card or 0 to go back to the Store Homepage");
                        int pick = InputControl.VerifyListChoiceStartingAt0(NumCards);
                        if (pick == -1)
                        {
                            NextPage = "STORE HOMEPAGE";
                        }
                        else
                        {
                            CardChosen = CardOptions[pick];
                            NextPage   = DisplayConfirmOrder(ShoppingCart, CardChosen, CurrentCustomer, CurrentLocation, Quantities);
                        }
                    }
                }
            }
            return(NextPage);
        }
Exemple #8
0
        internal static void DisplayPastOrders(Customer CurrentCustomer)
        {
            Console.WriteLine($"\n----PAST-ORDERS-FOR-{CurrentCustomer.FirstName}-{CurrentCustomer.LastName}----");
            List <Order> OrdersByCustomer;
            List <List <OrderProducts> > OPs;
            List <List <Product> >       PIOs;

            (OrdersByCustomer, OPs, PIOs) = DatabaseControl.GetOrdersInfo(CurrentCustomer);

            if (OrdersByCustomer.Count == 0)
            {
                Console.WriteLine("\nYou do have not placed any orders!");
                Console.WriteLine("Hit any key to go back.");
                Console.ReadLine();
            }
            else
            {
                foreach (Order o in OrdersByCustomer)
                {
                    Location l = DatabaseControl.GetOrderLocation(o);
                    Console.WriteLine("\n---------------------------------------------------------------------");
                    Console.WriteLine($"Order #{o.OrderID} made from {l.Name} at {o.OrderTime}:");
                    Console.WriteLine("-----------------------------------------------------------------------");
                    int NumItems = 1;
                    int Cost     = 0;
                    int PIOIndex = OrdersByCustomer.IndexOf(o);
                    foreach (Product p in PIOs[PIOIndex])
                    {
                        int OPIndex = PIOs[PIOIndex].IndexOf(p);
                        Console.WriteLine($"\nItem {NumItems}:" +
                                          $"\nName: {p.Name}" +
                                          $"\nQuantity: {OPs[PIOIndex][OPIndex].Quantity}" +
                                          $"\nPrice: ${p.Price * OPs[PIOIndex][OPIndex].Quantity}" +
                                          $"\nDescription: {p.Description}");
                        NumItems++;
                        Cost += (p.Price * OPs[PIOIndex][OPIndex].Quantity);
                    }
                    Console.WriteLine($"Total Cost = ${Cost}");
                }
                Console.WriteLine("\nHit any key to go back.");
                Console.ReadLine();
            }
        }
Exemple #9
0
        internal static void DisplayPastOrdersFromLocation(Location CurrentLocation)
        {
            Console.WriteLine($"\n--------{CurrentLocation.Name}-PAST-ORDERS---------");
            List <Order> OrdersFromHere;
            List <List <OrderProducts> > OPs;
            List <List <Product> >       PIOs;

            (OrdersFromHere, OPs, PIOs) = DatabaseControl.GetOrdersInfoFromLocation(CurrentLocation);

            if (OrdersFromHere.Count == 0)
            {
                Console.WriteLine("\nThere are currently no orders placed from here!");
                Console.WriteLine("Hit any key to go back.");
                Console.ReadLine();
            }
            else
            {
                foreach (Order o in OrdersFromHere)
                {
                    Console.WriteLine("\n--------------------------------------------");
                    Console.WriteLine($"Order #{o.OrderID} made at {o.OrderTime}:");
                    Console.WriteLine("--------------------------------------------");
                    int NumItems = 1;
                    int Cost     = 0;
                    int PIOIndex = OrdersFromHere.IndexOf(o);
                    foreach (Product p in PIOs[PIOIndex])
                    {
                        int OPIndex = PIOs[PIOIndex].IndexOf(p);
                        Console.WriteLine($"\nItem {NumItems}:" +
                                          $"\nName: {p.Name}" +
                                          $"\nQuantity: {OPs[PIOIndex][OPIndex].Quantity}" +
                                          $"\nPrice: ${p.Price * OPs[PIOIndex][OPIndex].Quantity}" +
                                          $"\nDescription: {p.Description}");
                        NumItems++;
                        Cost += (p.Price * OPs[PIOIndex][OPIndex].Quantity);
                    }
                    Console.WriteLine($"Total Cost = ${Cost}");
                }
                Console.WriteLine("\nHit any key to go back.");
                Console.ReadLine();
            }
        }
Exemple #10
0
        /// <summary>
        /// Makes calls to DisplayRegistation() page or DisplayLoginPage() based on users choice.
        /// Makes calls to DatabaseControl to store or verify the users information
        /// If user log in is invalid, method calls LoginFailed()
        /// If user selected to quit, method does nothing and passes control forward
        /// Otherwise, method sets the NextPage to 'CUSTOMER HOMEPAGE'
        /// </summary>
        /// <param name="UserChoice"></param>
        /// <returns>NextPage, CurrentCustomer</returns>
        internal static (string, Customer) DisplayLoginRegisterOrQuit(string UserChoice)
        {
            string   NextPage        = "CUSTOMER HOMEPAGE";
            Customer CurrentCustomer = new Customer();

            if (UserChoice == "REGISTER")
            {
                UserAccount Account = DisplayRegistrationPage();

                Console.WriteLine("\nFirst Name:");
                string fn = Console.ReadLine();
                Console.WriteLine("\nLast Name:");
                string ln = Console.ReadLine();

                Customer c = new Customer
                {
                    FirstName = fn,
                    LastName  = ln
                };

                DatabaseControl.RegisterAccount(Account, c);
                CurrentCustomer = DatabaseControl.GetCurrentCustomer(Account);
            }
            else if (UserChoice == "LOG IN")
            {
                UserAccount Account = DisplayLoginPage();
                if (DatabaseControl.LoginSuccesful(Account))
                {
                    CurrentCustomer = DatabaseControl.GetCurrentCustomer(Account);
                }
                else
                {
                    NextPage = DisplayLoginFailed();
                }
            }
            else if (UserChoice == "QUIT")
            {
                NextPage = "QUIT";
            }
            return(NextPage, CurrentCustomer);
        }
Exemple #11
0
        /// <summary>
        /// Calls DatabaseControl to find the locationss that carry the chosen product
        /// and displays those to the user
        /// Calls InputControl to get the users store choice, or reroutes if there are no stores
        /// which currently sell the product selected
        /// </summary>
        /// <param name="ProductToBuy"></param>
        /// <returns>NextPage, CurrentLocation</returns>
        internal static (string, Location) DisplayLocationsWithProduct(Product ProductToBuy)
        {
            string   NextPage        = "GO BACK";
            Location CurrentLocation = null;

            List <int> LocationIDs = DatabaseControl.FindLocationIDsWithProduct(ProductToBuy);

            if (LocationIDs.Count() > 0)
            {
                Console.WriteLine("----------------------STORES---------------------------");
                Console.WriteLine("\nThe following stores currently have your item in stock:");

                List <Location> StoreOptions = DatabaseControl.FindLocationsWithProduct(ProductToBuy, LocationIDs);

                int NumStores = 1;
                foreach (Location l in StoreOptions)
                {
                    Console.WriteLine($"\n\nStore #{NumStores}" +
                                      $"\n--------------{l.Name}--------------" +
                                      $"\n{l.AddressNum} {l.AddressStreet} " +
                                      $"\n{l.AddressCity}, {l.AddressState} {l.AddressZipCode}");
                    NumStores++;
                }
                Console.WriteLine("\nWhich store would you like to order from? Enter the store number to proceed");
                int choice = InputControl.VerifyListChoiceStartingAt1(NumStores);

                CurrentLocation = StoreOptions[choice];
                NextPage        = "STORE HOMEPAGE";
            }
            else
            {
                Console.WriteLine("\n\n-----------------ERROR--------------------");
                Console.WriteLine("\nWe are sorry, no stores currently carry that product.");
                Console.WriteLine("\n---Routing you back to make another selection.---");
                Thread.Sleep(2000);
            }
            return(NextPage, CurrentLocation);
        }