Ejemplo n.º 1
0
        public void Execute()
        {
            var prompts = new UserPrompts();
            var ops = new OrderOperations();
            EditOrderPrompts query;
            var response = new Response();
            var slip = new OrderSlip();
            bool tryAgain = false;

            do
            {
                tryAgain = false;
                slip = prompts.GetOrderInfoFromUser();
                response = ops.GetOrder(slip.OrderNumber, slip.Date);
                if (!response.Success)
                {
                    Console.WriteLine(response.Message);
                    tryAgain = prompts.PromptUserToTryAgain();
                }
                else
                {
                    query = new EditOrderPrompts(response.Order);
                    var queryResponse = query.EditOrder();

                    if (queryResponse.Updated)
                    {
                        ops.EditOrder(queryResponse.Order, slip.Date);
                    }

                    DisplayOrderInformation.DisplayEditOrderInfo(queryResponse.Order);
                }
            } while (tryAgain);
        }
Ejemplo n.º 2
0
        public void Execute()
        {
            var prompts = new UserPrompts();
            var orderSlipFromUser = prompts.GetOrderInfoFromUser();
            var ops = new OrderOperations();

            bool goAgain = false;

            do
            {
                var orderResponse = ops.GetOrder(orderSlipFromUser.OrderNumber, orderSlipFromUser.Date);

                if (!orderResponse.Success)
                {
                    Console.WriteLine(orderResponse.Message);
                    Console.WriteLine("Do you want to try again?");
                    string tryAgainOrNot = Console.ReadLine().ToUpper();
                    Console.Clear();

                    switch (tryAgainOrNot)
                    {
                        case "Y":
                            goAgain = true;
                            break;
                        case "N":
                            goAgain = false;
                            break;
                        default:
                            Console.WriteLine("That was not a valid input.");
                            break;
                    }
                }
                else
                {
                    DisplayOrderInformation.DisplayRemoveOrderInfo(orderResponse.Order);

                    var confirmation = prompts.RemovalConfirmation();

                    if (confirmation)
                    {
                        ops.RemoveOrder(orderSlipFromUser.OrderNumber, orderSlipFromUser.Date);
                        Console.WriteLine();
                        Console.WriteLine("Order removed. press any key to return to Main menu.");
                        Console.ReadKey();
                        goAgain = false;
                    }
                }
            } while (goAgain);
        }