Пример #1
0
        internal static void HandleOrder()
        {
            var orderRows = OrderRowHandlers.CreateOrderList();

            while (true)
            {
                MessageHandlers.DisplayOrderList(orderRows);
                MessageHandlers.AskForConfirmation();
                var answer       = UserInputHandlers.GetUserInput();
                var confirmation = UserInputHandlers
                                   .ValidateConfirmationAnswer(answer);
                if (confirmation.Item1)
                {
                    break;
                }
                var pizza = OrderRowHandlers.HandlePizzaChoice();
                if (pizza.Name != Pizzas.None.Name)
                {
                    pizza = OrderRowHandlers.HandleExtrasChoice(pizza);
                }
                var drink    = OrderRowHandlers.HandleDrinkChoice();
                var orderRow = OrderRowFactory.RowFactory
                               .CreateOrderRow(pizza, drink);
                var updatedOrder = OrderRowDecorator.RowDecorator
                                   .ReplaceOrderRow(confirmation.Item2, orderRow);
                OrderRows.Rows.OrderBy(row => row.RowId);
            }
            var rows  = OrderRows.Rows.ToList();
            var order = OrderFactory.Factory
                        .CreateOrder(rows);

            Orders.OrdersList.Add(order);
            MessageHandlers.PrintSubmitted();
        }
 public static Pizza HandleExtrasChoice(Pizza pizza)
 {
     while (true)
     {
         MessageHandlers.AskForExtras();
         var extraChoice     = UserInputHandlers.GetUserInput();
         var validatedChoice = UserInputHandlers
                               .ValidateExtrasChoice(extraChoice);
         if (!validatedChoice.Item1)
         {
             MessageHandlers.PrintWrongChoice();
         }
         else
         {
             var decorator = PizzaDecorator.Decorator;
             pizza = decorator
                     .AddExtras(pizza, validatedChoice.Item2);
             MessageHandlers.AskForMoreIngredients();
             var answer          = UserInputHandlers.GetUserInput();
             var validatedAnswer = UserInputHandlers
                                   .ValidateMoreAnswer(answer);
             if (!validatedAnswer)
             {
                 break;
             }
         }
     }
     return(pizza);
 }
        private static bool HandleMoreOrderRowsChoice()
        {
            MessageHandlers.AskForMoreOrderRows();
            var answer = UserInputHandlers.GetUserInput();

            return(UserInputHandlers.ValidateMoreAnswer(answer));
        }
 public static Soda HandleDrinkChoice()
 {
     while (true)
     {
         MessageHandlers.AskForDrinks();
         var drinkChoice     = UserInputHandlers.GetUserInput();
         var validatedChoice = UserInputHandlers
                               .ValidateDrinkChoice(drinkChoice);
         if (!validatedChoice.Item1)
         {
             MessageHandlers.PrintWrongChoice();
         }
         else
         {
             return(UserChoiceHandlers
                    .GetDrink(validatedChoice.Item2));
         }
     }
 }
 public static Pizza HandlePizzaChoice()
 {
     while (true)
     {
         MessageHandlers.AskForPizza();
         var pizzaChoice     = UserInputHandlers.GetUserInput();
         var validatedChoice = UserInputHandlers
                               .ValidatePizzaChoice(pizzaChoice);
         if (!validatedChoice.Item1)
         {
             MessageHandlers.PrintWrongChoice();
         }
         else
         {
             return(UserChoiceHandlers
                    .GetPizza(validatedChoice.Item2));
         }
     }
 }