static void Main(string[] args) { // Create database tables if none exist DatabaseInterface dab = new DatabaseInterface("BANGAZONCLI_DB"); dab.CheckCustomerTable(); dab.CheckOrderTable(); dab.CheckProductTable(); dab.CheckProductOrderTable(); dab.CheckPaymentTypeTable(); DbInitializer.Initialize(dab); // Seed the database if none exists // var db = new DatabaseInitializer(); // db.VerifyDataExists(); // Present the main menu from MainMenu.cs file MainMenu menu = new MainMenu(); CustomerManager cm = new CustomerManager(dab); OrderManager om = new OrderManager(dab); PaymentTypeManager ptm = new PaymentTypeManager(dab); ProductManager pm = new ProductManager(dab); // Read in the user's choice int choice; // If option 1 was chosen, create a new customer account do { // Show the main menu choice = menu.Show(); switch (choice) { // Menu option 1: Adding Customer case 1: CreateCustomer.DoAction(cm); break; // Menu option 2: Choosing Active Customer case 2: ChooseCustomer.DoAction(cm); break; // Menu option 3: Create Payment Options case 3: AddPayment.AddPay(ptm); break; // Menu option 4: Add product to sell case 4: CreateProduct.DoAction(pm); break; // Menu option 5: Add product to shopping cart case 5: AddProductCart.DoAction(om, pm, cm); break; // Menu option 6: Complete an order case 6: break; // Menu option 7: Remove customer product case 7: break; // Menu option 8: Update product information case 8: break; // Menu option 9: Show stale products case 9: break; // Menu option 10: Show customer revenue report case 10: break; // Menu option 11: Show overall product popularity case 11: break; } } while (choice != 12); }
static void Main(string[] args) { // Seed the database if none exist /* Authored by Krissy Caron this creating a new instance of db and creating the folowing tables * usign the DatabaseInterface.cs as a blue print. */ DatabaseInterface db = new DatabaseInterface("BangazonCLI_db"); db.CheckCustomerTable(); db.CheckProductTypeTable(); db.CheckProductTable(); db.CheckPaymentTypeTable(); db.CheckOrdersTable(); db.CheckProductOrderTable(); // Why does this not need an instance of class DBPopulator? DBPopulator.Populate(db); //Instance of customer manager. CustomerManager manager = new CustomerManager(db); // Present the main menu Console.WriteLine("*************************************************"); Console.WriteLine("Welcome to Bangazon! Command Line Ordering System"); Console.WriteLine("*************************************************"); Console.WriteLine("1. Create a customer account"); Console.WriteLine("2. Choose active customer"); Console.Write("> "); // Read in the user's choice int choice; Int32.TryParse(Console.ReadLine(), out choice); /* Authored By Krissy Caron * If option 1 was chosen, create a new customer account will trigger the following in the CMD line. * A new instance of customer will then be created from each type the user inputs and sent to the db in to the correct columns and table. */ if (choice == 1) { Console.WriteLine("Enter customer first name"); Console.Write("> "); string firstName = Console.ReadLine(); Console.WriteLine("Enter customer last name"); Console.Write("> "); string lastName = Console.ReadLine(); Console.WriteLine("Enter customer email"); Console.Write(">"); string email = Console.ReadLine(); Console.WriteLine("Enter customer phone number"); Console.Write("> "); string phoneNumber = Console.ReadLine(); manager.CreateCustomer(firstName, lastName, email, phoneNumber, DateTime.Now); } /* Authored by Krissy Caron * If Option 2 is selected, the list of all customers is displayed to the console in a Numered list. * The user can select from the customers which to make active, and that will be stored in the ActiveCustomer. */ if (choice == 2) { Console.WriteLine("Which customer will be active?"); //Displays List of currently avaiable customers List <Customer> customersList = manager.GetCustomers(); foreach (Customer customer in customersList) { Console.WriteLine($"{customer.CustomerId}. {customer.FirstName} {customer.LastName}"); } Console.Write("> "); //Takes a string of the chosen customer which is a number, and makes it equal to the instance of that customer in the database. string chosenCustomer = Console.ReadLine(); CustomerManager.ActiveCustomer = manager.GetCustomer(int.Parse(chosenCustomer)); //Takes Active customer and prints their name to console. Console.WriteLine("Active Customer is: " + CustomerManager.ActiveCustomer.FirstName + " " + CustomerManager.ActiveCustomer.LastName); } }