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 static AllEventsTopItem ConvertRawHtmlToJson(string rawText) { AllEventsTopItem allEvents = JsonConvert.DeserializeObject <AllEventsTopItem>(rawText); return(allEvents); }