public async static Task <List <Venue> > getVenues(double latitude, double longitude) { var url = VenueRoot.GenerateUrl(latitude, longitude); var response = await client.GetAsync(url); var jsonContent = await response.Content.ReadAsStringAsync(); var venueRoot = JsonConvert.DeserializeObject <VenueRoot>(jsonContent); List <Venue> vanues = venueRoot.response.venues as List <Venue>; return(vanues); }
public async Task <List <Venue> > GetVenues(double latitude, double longitude) { var url = VenueRoot.GenerateURL(latitude, longitude); var response = await _httpClient.GetAsync(url); var json = await response.Content.ReadAsStringAsync(); var venueRoot = JsonConvert.DeserializeObject <VenueRoot>(json); var venues = venueRoot.Response.Venues as List <Venue>; return(venues); }
public static async Task <List <Venue> > GetVenuesAsync(double latitude, double longitude) { var venues = new List <Venue>(); var url = VenueRoot.GenerateURL(latitude, longitude); using (HttpClient client = new HttpClient()) { var response = await client.GetAsync(url); var json = await response.Content.ReadAsStringAsync(); var venueRoot = JsonConvert.DeserializeObject <VenueRoot>(json); venues = venueRoot.response.venues as List <Venue>; } return(venues); }
public async static Task <List <Venue> > GetVenues(double latitude, double longitude) { List <Venue> Venues = new List <Venue>(); var URL = VenueRoot.GenerateURL(latitude, longitude); using (HttpClient Client = new HttpClient()) { var Response = await Client.GetAsync(URL); var Json = await Response.Content.ReadAsStringAsync(); var VenueRoot = JsonConvert.DeserializeObject <VenueRoot>(Json); Venues = VenueRoot.Response.venues as List <Venue>; } return(Venues); }
public static async Task <List <Venue> > GetVenues(double latitude, double longitude) { var venues = new List <Venue>(); string url = VenueRoot.GenerateUrl(latitude, longitude); using (var http = new HttpClient()) { var response = await http.GetAsync(url); var result = await response.Content.ReadAsStringAsync(); var venueRoot = JsonConvert.DeserializeObject <VenueRoot>(result); venues = venueRoot.response.venues; } return(venues); }
public async static Task <List <Venue> > GetVenues(double latitude, double longitude) // return a list of Venues, for a given location { // had to be static as 'await' used below, and had to be Task<> as returning non-void in an async List <Venue> venues = new List <Venue>(); var url = VenueRoot.GenerateURL(latitude, longitude); using (HttpClient client = new HttpClient()) { var response = await client.GetAsync(url); var json = await response.Content.ReadAsStringAsync(); var venueRoot = JsonConvert.DeserializeObject <VenueRoot>(json); // Use NewtonSoft JSON plugin to deserialize await'd json response venues = venueRoot.response.venues as List <Venue>; // here will be a list of Venue objects } return(venues); }
public async static Task <List <Venue> > GetVenues(double Latitude, double Longitude) { List <Venue> venues = new List <Venue>(); var url = VenueRoot.GenerateURL(Latitude, Longitude); using (HttpClient client = new HttpClient()) { var response = await client.GetAsync(url); if (!string.IsNullOrWhiteSpace(response.ToString())) { var json = await response.Content.ReadAsStringAsync(); //Debug.WriteLine(json.ToString()); var venueRoot = JsonConvert.DeserializeObject <VenueRoot>(json); venues = venueRoot.response.venues as List <Venue>; } } return(venues); }
public async static Task <List <Venue> > GetVenuesAsync(double latitude, double longitude) { List <Venue> venues = new List <Venue>(); var url = VenueRoot.GenerateURL(latitude, longitude); using (HttpClient client = new HttpClient()) { //json content from the api (rest service) var response = await client.GetAsync(url); //get the json string from the response variable var json = await response.Content.ReadAsStringAsync(); //deserialises the json against the C# objects var venueRoot = JsonConvert.DeserializeObject <VenueRoot>(json); string theshortname = venueRoot.response.venues[0].location.city; venues = venueRoot.response.venues as List <Venue>; } return(venues); }