Example #1
0
        public override void RowSelected(UITableView tableView, NSIndexPath indexPath)
        {
            var sectionModel    = SectionData[indexPath.Section];
            var currentMenuItem = sectionModel.RowContent[indexPath.Row];
            var newMenuItem     = currentMenuItem.Clone();

            newMenuItem.IsAvailable = !newMenuItem.IsAvailable;

            SoupMenuManager.ReplaceMenuItem(currentMenuItem, newMenuItem);
            ReloadData();
        }
        override public void ConfirmOrderSoup(OrderSoupIntent intent, Action <OrderSoupIntentResponse> completion)
        {
            // The confirm phase provides an opportunity for you to perform any
            // final validation of the intent parameters and to verify that any
            // needed services are available. You might confirm that you can
            // communicate with your company’s server.
            var soupMenuManager = new SoupMenuManager();

            var soup = intent.Soup;

            if (soup is null)
            {
                completion(new OrderSoupIntentResponse(OrderSoupIntentResponseCode.Failure, null));
                return;
            }

            var identifier = soup.Identifier;

            if (identifier is null)
            {
                completion(new OrderSoupIntentResponse(OrderSoupIntentResponseCode.Failure, null));
                return;
            }

            var menuItem = soupMenuManager.FindItem(identifier);

            if (menuItem is null)
            {
                completion(new OrderSoupIntentResponse(OrderSoupIntentResponseCode.Failure, null));
                return;
            }

            if (!menuItem.IsAvailable)
            {
                // Here's an example of how to use a custom response for a
                // failure case when a particular soup item is unavailable.
                completion(OrderSoupIntentResponse.FailureSoupUnavailableIntentResponseWithSoup(soup));
                return;
            }

            // Once the intent is validated, indicate that the intent is ready
            // to handle.
            completion(new OrderSoupIntentResponse(OrderSoupIntentResponseCode.Ready, null));
        }