static async Task <MapData[]> AsyncParser(string RestaurantName, double lat, double longi) { Console.WriteLine("Hello World"); var client = new Yelp.Api.Client("aH_2cWcPiZ4d-HQoo4B6iE_lsEM199j3cIH5RoKErtdKwPLc6ugHKKljAqfrx_hJXE-pXClCYrcK3VoRKFnUmgEqDAhEpCHj8GN9420tUO-4wK5gzJzCBDohs0cBWnYx"); return(await search(client, 10, 10)); }
static async Task AsyncMain(string[] args) { Console.WriteLine("Hello World"); var client = new Yelp.Api.Client("aH_2cWcPiZ4d-HQoo4B6iE_lsEM199j3cIH5RoKErtdKwPLc6ugHKKljAqfrx_hJXE-pXClCYrcK3VoRKFnUmgEqDAhEpCHj8GN9420tUO-4wK5gzJzCBDohs0cBWnYx"); await search(client); }
//search through restaurants private async void btnSearch_Click(object sender, RoutedEventArgs e) { //if the text is empty, don't let them search if (tbLocation.Text == "" || tbSearch.Text == "") { ContentDialog badInputDialog = new ContentDialog() { Title = "Bad search input", Content = "Please check search values", CloseButtonText = "Ok" }; await badInputDialog.ShowAsync(); return; } //get search data searchData.searchKeyWord = tbSearch.Text; searchData.searchLocation = tbLocation.Text; //set up yelp api client var client = new Yelp.Api.Client("uhYZFxMUHsPL7QO5AWYmIVGnrO1n_neqgTDJLZwQyFT2oHCzABvq5_BuXljPrjfS_DO3gkVoRwW2msSEj01JnP7gZAh1BEsDj2wz8zUO8m-Ka9eKrXRypgGzHYS6WnYx"); //set up the request var request = new Yelp.Api.Models.SearchRequest(); request.Term = searchData.searchKeyWord; request.Location = searchData.searchLocation; //send request async and get results var results = await client.SearchBusinessesAllAsync(request); int resultCount = results.Businesses.Count; //for each result, make a restaurant model and add it to search data for (int i = 0; i < resultCount; i++) { RestaurantModel rm = new RestaurantModel(results.Businesses[i].Name, results.Businesses[i].Phone, results.Businesses[i].Rating, results.Businesses[i].Categories, results.Businesses[i].Url, results.Businesses[i].Location.Address1, results.Businesses[i].Location.Country, results.Businesses[i].Location.State, results.Businesses[i].Location.City, results.Businesses[i].Location.ZipCode, results.Businesses[i].ImageUrl, results.Businesses[i].IsClosed); searchData.Restaurants.Add(rm); } //Navigate to search results page this.Frame.Navigate(typeof(SearchResults)); }
public async Task <Message> RetrieveIntent(Query inboundQuery) { var config = new AIConfiguration(ConfigurationManager.AppSettings["APIAI_TOKEN"], SupportedLanguage.English); apiAi = new ApiAi(config); var response = apiAi.TextRequest(inboundQuery.Body); var intent = response.Result.Metadata.IntentName; if (intent == null) { return(new Message() { Body = response.Result.Fulfillment.Speech }); } else { var city = response.Result.Parameters.Where(p => p.Key == "geo-city").FirstOrDefault().Value.ToString(); var state = response.Result.Parameters.Where(p => p.Key == "geo-state-us").FirstOrDefault().Value.ToString(); if (city == "") { return(new Message() { Body = "Please try again with a particular city." }); } else { var client = new Yelp.Api.Client(ConfigurationManager.AppSettings["YELPAPI_ID"], ConfigurationManager.AppSettings["YELPAPI_TOKEN"]); var request = new Yelp.Api.Models.SearchRequest(); request.Term = intent; request.Location = city; request.MaxResults = 5; request.OpenNow = true; var results = await client.SearchBusinessesAllAsync(request); return(new Message() { Body = intent + " in " + city + " " + state, Businesses = results.Businesses }); } } }
static async Task <IList <BusinessResponse> > search(Yelp.Api.Client client, double lat, double longi) { SearchResponse results = await client.SearchBusinessesAllAsync("Restaurants", lat, longi); IList <BusinessResponse> filteredList = results.Businesses.Where(b => b.Rating > 3.0).ToList(); List <MapData> restaurantsList = new List <MapData>(); foreach (var b in results.Businesses) { restaurantsList.add(new MapData(b.Latitute, b.Longitude, b.Name, b.Rating)) /*Console.WriteLine("Name: " + b.Name); * Console.WriteLine("Location: " + b.Location); * Console.WriteLine("Distance: " + b.Distance); * Console.WriteLine("Rating: " + b.Rating);*/ } return(filteredList); }
//static async Task<IList<BusinessResponse>> search(Yelp.Api.Client client, double lat, double longi static async Task <MapData[]> search(Yelp.Api.Client client, double lat, double longi) { SearchResponse results = await client.SearchBusinessesAllAsync("Restaurants", lat, longi); IList <BusinessResponse> filteredList = results.Businesses.Where(b => b.Rating > 3.0).ToList(); List <MapData> restaurantsList = new List <MapData>(); foreach (var b in results.Businesses) { double[] thing = AddresstoLatLong(b.Location.Address1, b.Location.City, b.Location.State); restaurantsList.Add(new MapData(thing[0], thing[1], b.Name, b.Rating)); /*Console.WriteLine("Name: " + b.Name); * Console.WriteLine("Location: " + b.Location); * Console.WriteLine("Distance: " + b.Distance); * Console.WriteLine("Rating: " + b.Rating);*/ } //Return an array return(restaurantsList.ToArray()); }