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
        static void Main(string[] args)
        {
            MainMenu            menu = new MainMenu();
            DatabaseInitializer db   = new DatabaseInitializer("bangazon_cli_db");
            CustomerManager     cm   = new CustomerManager(db);


            int choice;

            do
            {
                // Show the Main Menu
                choice = menu.Show();

                switch (choice)
                {
                case 1:
                    // Displays the Create Customer Menu
                    AddCustomerMenu.Show(cm);
                    break;
                    // case 2:
                    //     ChooseCustomer.ChooseCustomerMenu(cm, db);
                    //     break;
                    // case 3:
                    //     if (CustomerManager.currentCustomer == null)
                    //     {
                    //         ChooseCustomer.ChooseCustomerMenu(cm, db);
                    //     }
                    //     CreatePayment.CreatePaymentMenu(paytm);
                    //     break;
                    // case 4:
                    //     if (CustomerManager.currentCustomer == null)
                    //     {
                    //         ChooseCustomer.ChooseCustomerMenu(cm, db);
                    //     }
                    //     AddProductToSell.DoAction(pm, ptm);
                    //     break;
                    // case 5:
                    // if (CustomerManager.currentCustomer == null)
                    //     {
                    //         ChooseCustomer.ChooseCustomerMenu(cm, db);
                    //     }
                    //     AddProductOrder.AddProductToOrder(cm, pm, om);
                    //     break;
                    // case 6:
                    //      if (CustomerManager.currentCustomer == null)
                    //         {
                    //             ChooseCustomer.ChooseCustomerMenu(cm, db);
                    //         }
                    //     CompleteOrder.CompleteOrderMenu(om, pm, paytm);
                    //     break;
                    // case 7:
                    //     if (CustomerManager.currentCustomer == null)
                    //     {
                    //         ChooseCustomer.ChooseCustomerMenu(cm, db);
                    //     }
                    //     RemoveProductToSell.RemoveProductToSellMenu(pm);
                    //     break;
                    // case 8:
                    //     if (CustomerManager.currentCustomer == null)
                    //     {
                    //         ChooseCustomer.ChooseCustomerMenu(cm, db);
                    //     }
                    //     UpdateProduct.UpdateProductMenu(pm);
                    //     break;
                    // case 9:
                    //     if (CustomerManager.currentCustomer == null)
                    //     {
                    //         ChooseCustomer.ChooseCustomerMenu(cm, db);
                    //     }
                    //     ShowStale.DoAction(om);
                    //     break;
                    // case 10:
                    //     if (CustomerManager.currentCustomer == null)
                    //     {
                    //         ChooseCustomer.ChooseCustomerMenu(cm, db);
                    //     }
                    //     RevenueReport.ShowRevenueReport(om);
                    //     break;
                    // case 11:
                    //     ProductPopularityReport.ProductPopularityReportMenu(pm);
                    //     break;
                }
            } while(choice != 12);
        }