private async Task TryResolveAddressAsync()

in CSharp/BotBuilderLocation/Dialogs/RichLocationRetrieverDialog.cs [84:113]


        private async Task TryResolveAddressAsync(IDialogContext context, IMessageActivity message)
        {
            var locationSet = await this.geoSpatialService.GetLocationsByQueryAsync(message.Text);
            var foundLocations = locationSet?.Locations;

            if (foundLocations == null || foundLocations.Count == 0)
            {
                await context.PostAsync(this.ResourceManager.LocationNotFound);

                context.Wait(this.MessageReceivedAsync);
            }
            else
            {
                this.locations.AddRange(foundLocations.Take(MaxLocationCount));

                var locationsCardReply = context.MakeMessage();
                locationsCardReply.Attachments = this.cardBuilder.CreateHeroCards(this.locations).Select(C => C.ToAttachment()).ToList();
                locationsCardReply.AttachmentLayout = AttachmentLayoutTypes.Carousel;
                await context.PostAsync(locationsCardReply);

                if (this.locations.Count == 1)
                {
                    this.PromptForSingleAddressSelection(context);
                }
                else
                {
                    await this.PromptForMultipleAddressSelection(context);
                }
            }
        }