public async Task <List <PlaceAttributes> > GetAllData(String DeparturePlace, String ArrivalDateTime, String DepartureDateTime, String PointOfInterest) { try { var _googleClient = _httpClientFactory.CreateClient("GoogleClient"); Uri endpoint = _googleClient.BaseAddress; // Returns GoogleApi var Key = _iconfiguration["GoogleAPI"]; var Url = endpoint.ToString() + "maps/api/place/textsearch/json?query=" + PointOfInterest + "+in+" + DeparturePlace + "&language=en&key=" + Key; var _client = _httpClientFactory.CreateClient(); var response = await _client.GetAsync(Url); response.EnsureSuccessStatusCode(); string responseBody = await response.Content.ReadAsStringAsync(); RootobjectOfData data = JsonConvert.DeserializeObject <RootobjectOfData>(responseBody); List <PlaceAttributes> Data = data.results.TransalateData(Key, endpoint); List <PlaceAttributes> SortedList = Data.OrderBy(o => o.Rating).ToList(); return(SortedList); } catch (Exception e) { Console.WriteLine(e.Message); } return(null); }
public async Task <List <PlaceAttributes> > GetData(LocationAttributes Position, String DeparturePlace, String ArrivalDateTime, String DepartureDateTime, String PointOfInterest) { try { //using (HttpClient client = new HttpClient()) //{ var client = _httpClientFactory.CreateClient(Constants.GoogleClient); Uri endpoint = client.BaseAddress; // Returns GoogleApi var Key = _iconfiguration["GoogleAPI"]; //var Url = endpoint.ToString() + "maps/api/place/nearbysearch/json?location=18.579343,73.9089168&radius=1000&type=" + PointOfInterest + "&key=" + Key; var Url = endpoint.ToString() + "maps/api/place/nearbysearch/json?location=" + Position.LatitudePosition + "," + Position.LongitudePosition + "&radius=1000&type=" + PointOfInterest + "&key=" + Key; var client1 = _httpClientFactory.CreateClient(); var response = await client1.GetAsync(Url); response.EnsureSuccessStatusCode(); string responseBody = await response.Content.ReadAsStringAsync(); RootobjectOfData data = JsonConvert.DeserializeObject <RootobjectOfData>(responseBody); List <PlaceAttributes> Data = data.results.TransalateData(Key, endpoint); return(Data); } catch (Exception e) { Console.WriteLine(e.Message); } return(null); }