public void addLatLng(float lat, float lng)
 {
     latitude          = lat;
     longitude         = lng;
     formatted_address = MapsApi.getFormattedAddress(this);
     iconURL           = MapsApi.getStaticImageURL(this);
 }
 public bool setLocationLucky(string searchQuery)
 {
     try
     {
         List <Location> searchResults = MapsApi.getSearchResults(searchQuery);
         this.addLatLng(searchResults[0].latitude, searchResults[0].longitude);
         this.name = searchResults[0].name;
         return(true);
     }
     catch
     {
         return(false);
     }
 }
        /// <summary>
        /// Sets the location a search query and clarifies if necessary
        /// </summary>
        /// <param name="context">Conversation context</param>
        /// <param name="searchQuery">Name of location to add</param>
        /// <returns>returns false if 0 results, true otherwise.</returns>
        public bool setLocation(IDialogContext context, string searchQuery)
        {
            List <Location>  searchResults = MapsApi.getSearchResults(searchQuery);
            IMessageActivity validate      = context.MakeMessage();

            validate.AttachmentLayout = AttachmentLayoutTypes.Carousel;
            validate.Attachments      = new List <Attachment>();
            foreach (Location searchResult in searchResults)
            {
                HeroCard         resultCard  = new HeroCard();
                CardImage        resultImage = new CardImage();
                List <CardImage> cardImages  = new List <CardImage>(1);
                resultImage.Url = searchResult.iconURL;
                cardImages.Add(resultImage);
                resultCard.Title  = searchResult.formatted_address;
                resultCard.Images = cardImages;
                validate.Attachments.Add(resultCard.ToAttachment());
            }
            context.PostAsync(validate);
            return(searchResults.Count > 0);
        }