Exemplo n.º 1
0
        static void Main(string[] args)
        {
            // Initalize the interface
            string            prodPath = System.Environment.GetEnvironmentVariable("BANGAZON_CLI_APP_DB");
            DatabaseInterface db       = new DatabaseInterface(prodPath);

            // Initialize the Manager objects
            CustomerManager       customerManager       = new CustomerManager(db);
            ActiveCustomerManager activeCustomerManager = new ActiveCustomerManager(customerManager);
            ProductManager        productManager        = new Managers.ProductManager(db);
            OrderManager          orderManager          = new OrderManager(db);
            PaymentTypeManager    paymentTypeManager    = new PaymentTypeManager(db);

            Customer activeCustomer = new Customer();

            int choice;

            // When the user enters the system show the main menu
            do
            {
                choice = MainMenu.Show(activeCustomer);

                switch (choice)
                {
                // Add customer
                case 1:
                {
                    AddCustomerMenu customerMenu = new AddCustomerMenu(new Customer(), customerManager);
                    customerMenu.Show();
                    break;
                }

                /*
                 *  List the customers and allow the user to select a customer based on the
                 *  position in the list
                 */
                case 2:
                {
                    ActiveCustomerMenu activeCustomerMenu = new ActiveCustomerMenu(customerManager);
                    int customerId = activeCustomerMenu.Show();
                    activeCustomer = activeCustomerManager.SetActiveCustomer(customerId);
                    break;
                }

                /*
                 *  Add a new payment type for a customer
                 */

                case 3:
                {
                    PaymentTypeMenu addPaymentTypeMenu = new PaymentTypeMenu(new PaymentType(), paymentTypeManager, activeCustomer);
                    addPaymentTypeMenu.Show();
                    break;
                }

                /*
                 *  Add product to active customer
                 */
                case 4:
                {
                    AddProductMenu addProductMenu = new AddProductMenu(activeCustomer, new Product(), productManager);
                    addProductMenu.Show();
                    break;
                }

                /*
                 *  Update an active customer's product
                 */
                case 5:
                {
                    UpdateProductMenu updateProductMenu = new UpdateProductMenu(activeCustomer, productManager);
                    updateProductMenu.Show();
                    break;
                }



                /*
                 *  List the active customer's product(s)
                 *  The user cannot delete products that are on active orders
                 */
                case 6:
                {
                    DeleteActiveCustomerProductsMenu menu = new DeleteActiveCustomerProductsMenu(activeCustomer, productManager);
                    menu.Show();
                    break;
                }

                /*
                 *  Lists all products to allow user to choose one to add to their order. When product is chosen, the product is added to the active customer's order
                 */

                case 7:
                {
                    AddProductToCartMenu addProductToCartMenu = new AddProductToCartMenu(activeCustomer, orderManager, productManager);
                    addProductToCartMenu.Show();
                    break;
                }

                /*
                 *  Allow user to complete order.
                 *  Checks to make sure active customer's order contains products
                 *  If products exist on order, displays the total order amount in dollars.
                 *  Allows user to Add Payment type to their order.
                 */

                case 8: {
                    CloseOrderMenu closeOrderMenu = new CloseOrderMenu(activeCustomer, orderManager, productManager, paymentTypeManager);
                    closeOrderMenu.Show();
                    break;
                }


                default:
                {
                    break;
                }
                }
            } while (choice != 10);
        }
Exemplo n.º 2
0
        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();
            }
        }