Esempio n. 1
0
        public async Task SearchCuisines(IDialogContext context, LuisResult result)
        {
            string message = $"Welcome to the Cuisine finder! Give me a second as I analyze your cusine search: '{result.Query}'...";

            await context.PostAsync(message);

            SearchMealRequest searchMealRequest = GetSearchCuisineRequest(result);


            Dictionary <string, int> cuisineDict = _externalService.CuisineDictionary();

            if (!cuisineDict.ContainsKey(searchMealRequest.Cuisine))
            {
                await HandleUnkownCuisine(context, searchMealRequest, cuisineDict, OnEnterOtherCuisine);
            }
            else
            {
                searchMealRequest.CuisineId = cuisineDict[searchMealRequest.Cuisine];

                searchMealRequest.AddressesArray = _externalService.GetAddressesArray(searchMealRequest.Location);

                if (searchMealRequest.AddressesArray != null)
                {
                    if (searchMealRequest.AddressesArray.Length == 1)
                    {
                        PromptForAddressConfirmation(context, searchMealRequest, OnSingleAddressConfirmation);
                    }
                    else
                    {
                        HandleMultiAddress(context, searchMealRequest, OnMultiAddressTask);
                    }
                }
                else
                {
                    HandleNoMatchedAddress(context, searchMealRequest, OnSecondAddressTask);
                }
            }
        }