コード例 #1
0
        private async Task CreateOrder()
        {
            Customer customer = await AttemptAddCustomerToNewOrder();

            if (customer is null)
            {
                return;
            }

            ILocation location = await AttemptAddLocationToOrder();

            if (location is null)
            {
                return;
            }

            _currentOrder = new Order(customer, location);

            while (buildingOrder)
            {
                ResponseChoice response = new ResponseChoice(_io);
                response.Options.Add(new ChoiceOption("Add Product", AddNewProductToOrder));
                response.Options.Add(new ChoiceOption("Check Order Status", CheckStatus));
                response.Options.Add(new ChoiceOption("Cancel Order", CancelOrder));
                response.Options.Add(new ChoiceOption("Submit Order", TrySubmitOrder));
                await response.ShowAndInvokeOptions();
            }
        }
コード例 #2
0
        protected async Task TryAgain(string tryAgainText, string cancelText, Action tryAgain)
        {
            ResponseChoice response = new ResponseChoice(_io);

            response.Options.Add(new ChoiceOption(tryAgainText, tryAgain));
            response.Options.Add(new ChoiceOption(cancelText));
            await response.ShowAndInvokeOptions();
        }
コード例 #3
0
        public override async Task Open()
        {
            ResponseChoice response = new ResponseChoice(_io);

            response.Options.Add(new ChoiceOption("Search List of Customers", SearchListOfCustomers));
            response.Options.Add(new ChoiceOption("Search Orders by Customer", SearchOrdersByCustomer));
            response.Options.Add(new ChoiceOption("Search Orders by Store Location", SearchOrdersByLocation));
            response.Options.Add(new ChoiceOption("Go Back", ReturnToPreviousMenu));
            await response.ShowAndInvokeOptions();
        }
コード例 #4
0
        public override async Task Open()
        {
            while (true)
            {
                _io.Output.Write("Welcome to the store!");

                ResponseChoice response = new ResponseChoice(_io);
                response.Options.Add(new ChoiceOption("Place Order", PlaceOrder));
                response.Options.Add(new ChoiceOption("Search Database", Search));
                response.Options.Add(new ChoiceOption("Add Customer", AddCustomer));
                response.Options.Add(new ChoiceOption("Quit", Quit));
                await response.ShowAndInvokeOptions();

                _io.PressEnterToContinue();
            }
        }
コード例 #5
0
        private async Task DisplayOrdersWithSortOptions(IEnumerable <IReadOnlyOrder> orders)
        {
            bool isSearching = true;

            do
            {
                DisplayOrders(orders);

                ResponseChoice response = new ResponseChoice(_io);
                response.Options.Add(new ChoiceOption("Sort by earliest order time", () => orders        = orders.SortByEarliest()));
                response.Options.Add(new ChoiceOption("Sort by latest order time", () => orders          = orders.SortByLatest()));
                response.Options.Add(new ChoiceOption("Sort by cheapest total price", () => orders       = orders.SortByCheapest()));
                response.Options.Add(new ChoiceOption("Sort by most expensive total price", () => orders = orders.SortByMostExpensive()));
                response.Options.Add(new ChoiceOption("Stop searching", () => isSearching = false));
                await response.ShowAndInvokeOptions();
            } while (isSearching);
        }