public async Task <IEnumerable <Trail> > Get(string query) { int maxResults = 100; string http = "http"; string url = $"{http}://dev.virtualearth.net/REST/v1/Locations?query={query}&maxResults={maxResults}&key={Configuration["BingAPIKEY"]}"; _context.CreateBingSearch(url); using (var client = new HttpClient( )) { client.BaseAddress = new Uri("http://dev.virtualearth.net"); var response = await client.GetAsync($"http://dev.virtualearth.net/REST/v1/Locations?query={query}&maxResults={maxResults}&key={Configuration["BINGAPIKEY"]}"); response.EnsureSuccessStatusCode(); var stringResult = await response.Content.ReadAsStringAsync(); BingRootobject rawData = JsonConvert.DeserializeObject <BingRootobject>(stringResult); var coords1 = rawData.resourceSets[0].resources[0].point.coordinates[0]; var coords2 = rawData.resourceSets[0].resources[0].point.coordinates[1]; var rObject = _getTrails.CreateTrailsSearch(coords1, coords2); // add rObject to db await _trail.Create(rObject); var trailk = _trail.GetAll(query); //var output = from t in trailk // where (t.Location.Contains(query)) // select t; // var output2 = //query db //send query results back to user //return output; return(await trailk); //call iTralData to make a create to add to db } }
public async Task <IEnumerable <Trail> > GetAll(string query) { return(await _trail.GetAll(query)); }