private async Task SearchOrdersByCustomer()
        {
            ICustomer customer = await CustomerMenuHelper.LookUpCustomer(_io, _database);

            if (customer is null)
            {
                return;
            }

            IOrderRepository repo = _database.OrderRepository;
            var orders            = await repo.GetOrdersFromCustomer(customer);

            if (orders.Count == 0)
            {
                _io.Output.Write($"The customer '{customer.DisplayName()}' has no orders on record.");
                return;
            }

            await DisplayOrdersWithSortOptions(orders);
        }
Exemple #2
0
        private async Task <Customer> AttemptAddCustomerToNewOrder()
        {
            Customer customer = null;
            bool     tryAgain;

            do
            {
                tryAgain = false;

                _io.Output.Write("Please select a customer to order as:");

                customer = await CustomerMenuHelper.LookUpCustomer(_io, _database);

                if (customer is null)
                {
                    await TryAgain("Try again with a different customer", "Cancel order", () => tryAgain = true);
                }
            } while (tryAgain);

            return(customer);
        }