Exemplo n.º 1
0
        private static void UserView(User user)
        {
            bool     runLoop = true;
            MainMenu state   = MainMenu.Stores;

            while (runLoop)
            {
                switch (state)
                {
                case MainMenu.Stores:     //Prints all stores and select a store.
                    state = SelectTheStore(user);
                    break;

                case MainMenu.StoresOptions:     //Give options with selected store.
                    PrintStoreOptions();
                    Console.WriteLine($"Welcome to {user.SelectedStore}.");
                    state = SelectStoreOption();
                    break;

                case MainMenu.Order:
                    MakeOrder(user);
                    state = MainMenu.StoresOptions;
                    break;

                case MainMenu.ViewHistory:
                    user.Orders = _sql.ReadUsersOrders(user.Name);
                    ViewUserHistory(user.Orders);
                    state = MainMenu.StoresOptions;
                    break;

                case MainMenu.ViewStoreHistory:
                    var user_orders = _sql.ReadUsersOrdersFromStore(user);
                    Console.WriteLine(user.Name);
                    if (user_orders == null || user_orders.Count == 0)
                    {
                        Console.WriteLine($"Sorry, you do not have any orders with {user.SelectedStore}.");
                    }
                    else
                    {
                        ViewUserHistory(user_orders);
                    }
                    state = MainMenu.StoresOptions;
                    break;

                default:
                    runLoop = false;
                    break;
                }
            }
        }