public async Task <CoordinateService> Lookup(string location) { var cord = new CoordinateService() { Status = false, Message = "Unable to find the location : " + location }; //here comes the logic //var url = "http://www.gps-coordinates.net/api/eiffeltowe"; var url = $"http://maps.googleapis.com/maps/api/geocode/json?address={location.ToLower()}&sensor=false"; var client = new HttpClient(); var json = await client.GetStringAsync(url); var result = JObject.Parse(json); var resources = result["results"][0]["geometry"]["location"]; var status = (string)result["status"]; var lng = (string)resources["lng"]; var lat = (string)resources["lat"]; if (status == "OK") { cord.Latitude = Double.Parse(lat); cord.Longitude = Double.Parse(lng); cord.Status = true; cord.Message = "Co-ordinate have been found"; } //cord.Longitude = (double)resources["lng"]; return(cord); }
public StopController(IWorldRepository repository, ILogger<Stop> logger, CoordinateService coordinateService) { _repository = repository; _logger = logger; _coordinateService = coordinateService; }