private void searchButton_Click(object sender, EventArgs e) { if (eventTextbox.Text != "" && locationTextbox.Text != "" && radiusTextbox.Text != "" && float.TryParse(radiusTextbox.Text, out float result) && result > 0) { HideAllWarnings(); //get lat long of selected place LatLongFromLocation latLongLocation = new LatLongFromLocation(); Tuple <float, float> latLong = latLongLocation.GetLatLong(locationTextbox.Text); string eventSearchUrl = EventSearchUrlBuilder.BuildSearchUrl(eventTextbox.Text, latLong.Item1.ToString(), latLong.Item2.ToString(), radiusTextbox.Text); string results = HTTPrequests.GetHTTPRequestWithTicketMaster(eventSearchUrl); AllEventsTopItem items = EventHtmlToJsonConverter.ConvertRawHtmlToJson(results); if (float.Equals(latLong.Item1, -404) || float.Equals(latLong.Item2, -404)) { DisplayWarning("failed"); } else { // dynamically populate all the events on the right hand side ClearSidePanel(); if (items._embedded == null) { DisplayWarning("noResults"); } else { for (int i = 0; i < items._embedded.events.Count; i++) { CreateSidePanelEntry(items._embedded.events[i].name, items._embedded.events[i].info, items._embedded.events[i].dates.start.localDate + " at " + items._embedded.events[i].dates.start.localTime, items._embedded.events[i].url, i); } } } } else { DisplayWarning("warning"); } }
public Tuple <float, float> GetLatLong(string address) { string formatedText = address.Replace(" ", "+"); formatedText = formatedText.Replace(",", ""); // get rid of commas string url = urlBase + "address=" + formatedText; var response = HTTPrequests.GetHTTPRequestWithGoogle(url); if (response == null) { return(new Tuple <float, float>(-404, -404)); } else { LatLongResults results = Newtonsoft.Json.JsonConvert.DeserializeObject <LatLongResults>(response); return(new Tuple <float, float>(results.results[0].geometry.location.lat, results.results[0].geometry.location.lng)); } }
public string[] GetAutocomplete(string enteredText) { string formatedText = enteredText.Replace(" ", "+"); string url = urlBase + "input=" + formatedText; var response = HTTPrequests.GetHTTPRequestWithGoogle(url); //JObject json = JObject.Parse(response.ToString()); //Console.WriteLine(json); AutocompleteResults results = Newtonsoft.Json.JsonConvert.DeserializeObject <AutocompleteResults>(response); //Console.WriteLine(response.ToString()); int numResults = results.predictions.Count(); string[] returnResults = new string[numResults]; for (int i = 0; i < numResults; i++) { returnResults[i] = results.predictions[i].description; } return(returnResults); }