Exemplo n.º 1
0
        private async Task SearchListOfCustomers()
        {
            List <ICustomer> foundCustomers = await CustomerMenuHelper.SearchCustomer(_io, _database);

            if (foundCustomers.Count > 0)
            {
                _io.Output.Write("Customers found:");

                foundCustomers.ForEach(c => _io.Output.Write(c.DisplayName()));
            }
            else
            {
                _io.Output.Write("No customers found.");
            }
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
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);
        }