static void Main(string[] args) { DatabaseInterface db = new DatabaseInterface("BANGAZONCLI_DB"); db.CheckDatabaseTable("Customer", DbTables.Customer); db.CheckDatabaseTable("Product", DbTables.Product); db.CheckDatabaseTable("PaymentType", DbTables.PaymentType); db.CheckDatabaseTable("[Order]", DbTables.Order); db.CheckDatabaseTable("OrderProduct", DbTables.OrderProduct); DbInitializer.Initialize(db); MainMenu menu = new MainMenu(); CustomerManager customerManager = new CustomerManager(db); OrderManager orderManager = new OrderManager(db); // Choice will hold the number entered by the user // after main menu ws displayed int choice; do { // Show the main menu choice = menu.Show(); switch (choice) { case 1: AddCustomer.DoAction(customerManager); break; case 2: ChooseActiveCustomer.DoAction(customerManager); break; case 3: AddPaymentType.DoAction(customerManager); break; case 5: AddProductToCart.DoAction(orderManager); break; case 6: CloseOrder.DoAction(orderManager); break; } } while (choice != 7); }
public static List <Customer> ListOfCustomers() { DatabaseInterface db = new DatabaseInterface("BANGAZONCLI_DB"); db.Query("select id, firstname, lastname from customer", (SqliteDataReader reader) => { customers.Clear(); while (reader.Read()) { customers.Add(new Customer() { id = reader.GetInt32(0), FirstName = reader[1].ToString(), LastName = reader[2].ToString() }); } }); return(customers); }
public static void Initialize(DatabaseInterface dab) { bool customersExist = false; dab.Query($"select id from customer", (SqliteDataReader reader) => { while (reader.Read()) { customersExist = true; } if (customersExist == false) { dab.BulkInsert($@" insert into customer values(null, 'Bobby', 'Schmurda', 'Rykers Island', 'Brooklyn', 'NY', '12345', '555-555-5555'); insert into customer values(null, 'Lil', 'Pump', '2 Main St.', 'Miami', 'FL', '23456', '555-555-5551'); insert into customer values(null, 'Smoke', 'Purpp', '3 Main St.', 'Miami', 'FL', '34567', '555-555-5552'); insert into paymentType values(null, 'Cash', 1, 12); insert into paymentType values(null, 'Visa', 2, 13); insert into paymentType values(null, 'MasterCard', 3, 13); insert into [order] values (null, 1, 1); insert into [order] values(null, 2, 2); insert into [order] values(null, 3, 3); insert into product values (null, 'Codine Cough Syrup', 3, 12.99, 1, 'Goes great with Sprite!'); insert into product values (null, 'SoundCloud Subscription', 2, 9.99, 2, 'Where all the good hip hop is at'); insert into product values (null, 'Soccer Ball', 1, 10.99, 3, 'Kick goals with it!'); insert into productOrder values (null, 1, 2); insert into productOrder values (null, 2, 1); insert into productOrder values (null, 3, 3); "); } }); }
/* Created by Krissy Caron * The New Customer Manager Constructor creates a new db */ public CustomerManager(DatabaseInterface db) { _db = db; }
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); } }
public static void MainMenu() { // Seed the database if none exists DatabaseInterface db = new DatabaseInterface("BANGAZONCLI_DB"); db.CheckCustomerTable(); AddCustomerMenu _ACSB = new AddCustomerMenu(); db.CheckProductTable(); AddProductMenu _APSB = new AddProductMenu(); db.CheckPaymentTypeTable(); AddPaymentTypeMenu _APTSB = new AddPaymentTypeMenu(); db.CheckOrderTable(); AddOrderMenu _AOM = new AddOrderMenu(); db.CheckOrderProductTable(); RemoveProductMenu _RPM = new RemoveProductMenu(); 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.WriteLine("3. Create a Payment Type for Active Customer"); Console.WriteLine("4. Create product for active customer"); Console.WriteLine("5. Add product to customer order"); Console.WriteLine("6. See Available Products"); Console.WriteLine("7. Delete a customer's product"); Console.Write("> "); // Read in the user's choice int choice; Int32.TryParse(Console.ReadLine(), out choice); // If option 1 was chosen, create a new customer account if (choice == 1) { _ACSB.AddCustomerStringBuilder(new CustomerManager(db)); // public void AddCustomerStringBuilder } if (choice == 2) { ChooseActiveCustomerManager.ChooseActiveCustomer(); } if (choice == 3) { _APTSB.AddPaymentTypeStringBuilder(new PaymentTypeManager(db)); } if (choice == 4) { _APSB.AddProductStringBuilder(new ProductManager(db)); //public void AddProductStringBuilder } if (choice == 5) { _AOM.AddOrderStringBuilder(new ProductManager(db)); } if (choice == 6) { _AOM.AddOrderStringBuilder(new ProductManager(db)); } if (choice == 7) { _RPM.RemoveAProductStringBuilder(new ProductManager(db)); } else { MainMenu(); } }
public static void Main(string[] args) { // Seed the database if none exists var db = new DatabaseInterface("BANGAZON_TEST_DB"); db.CheckProdOrderTable(); db.CheckCustomerTable(); db.CheckOrderTable(); db.CheckPaymentTypeTable(); db.CheckProductTable(); db.CheckProductTypeTable(); // Create Instance of MenuManager T.L. MenuManager menu = new MenuManager(); CustomerManager customer = new CustomerManager(db); ProductTypeManager productType = new ProductTypeManager(db); PaymentManager payment = new PaymentManager(db); ProductTypeManager prodType = new ProductTypeManager(db); ProductManager product = new ProductManager(db); OrderManager order = new OrderManager(db); // int will hold active customer T.L. int activeCustomer = 0; // choice will hold the reference to the number the user selected // after the MenuManager was displayed T.L. int choice; do { // Display Menu from MenuManager // Save selected int to choice T.L choice = menu.ShowMenu(); Console.Clear(); switch (choice) { // if Menu option 1 is selected: Add new Customer // Method is called in CreateNewCustomer which calls Method in CustomerManager T.L. case 1: CreateNewCustomer.DoAction(customer); break; // if Menu option 2 is selected: // Method from GetCustomersAction makes a call to CustomersManager // Returns a list of Customers to display in terminal // The selected Customer's ID is stored in activeCustomer // This variable will then be passed to case 3 // Authored by : Tamela Lerma & Jason Smith case 2: activeCustomer = GetCustomersAction.DoAction(customer); break; // User will be prompted to first select a customer // once customer is selected // a Method in CreatePaymentAction is called which // calls a Method in PaymentTypeManager to create a new payment // Authored by : Tamela Lerma & Jason Smith case 3: if (activeCustomer != 0) { CreatePaymentAction.DoAction(payment, activeCustomer); } else { Warning("Please select customer first."); } break; // User will first be prompted to select an active customer // after customer is selected, a CreateProductAction Class Method is called // this Method accepts 3 arguments: Instance of ProductManager, Instance of ProductTypeManager, and the stored int for CustomerId // Authored by : Tamela Lerma case 4: if (activeCustomer != 0) { CreateProductAction.DoAction(product, activeCustomer, productType); } else { Warning("Please select customer first."); } break; // User will need to first select a active customer // once customer is selected // a Method in AddProductToCartAction is called which // calls a Method in ProductManager to add a product to customers order // Authored by : Azim case 5: if (activeCustomer != 0) { AddProductToCartAction.DoAction(order, product, activeCustomer); } else { Warning("Please select customer first."); } break; // User will be prompted to first choose active customer // then will call Method in CompleteOrderAction which // References PaymentManager and OrderManager // checks that payment exists for customer // payment is added to an order // Authored by : Jason Smith & Tamela Lerma case 6: if (activeCustomer != 0) { CompleteOrderAction.DoAction(activeCustomer, payment, order); } else { Warning("Please select customer first."); } break; // User will first be prompted to select a customer // after customer is selected, a DeleteProductAction Class Method is called // this Method accepts 2 arguments: Instance of ProductManager and the stored int for CustomerId // Will Delete Customer Products in DB // Authored by : Tamela Lerma case 7: if (activeCustomer != 0) { DeleteProductAction.DoAction(product, activeCustomer); } else { Warning("Please select customer first."); } break; // User will need to first select a active customer // once customer is selected // a Method in UpdateProduct is called which // calls a Method in ProductManager update the product of the customer // Authored by : Azim case 8: if (activeCustomer != 0) { UpdateProduct.DoAction(product, activeCustomer); } else { Warning("Please select customer first."); } break; case 9: GetStaleProducts.DoAction(product); break; // User will need to first select active customer // once customer is selected // a method in GetCustomerReport is called which // calls a method in OrderManger to return a report of active customer's sales // Authored by : Jason Smith case 10: if (activeCustomer != 0) { GetCustomerReport.DoAction(activeCustomer, customer, order); } else { Warning("Please select customer first."); } break; case 11: GetPopularProducts.DoAction(product); break; // Return, exiting program case 12: return; } } while(choice != 0); }