public async Task <GeoLocationCity> PostalCodeToLocationAsync(int postalCode) { var tcs = new TaskCompletionSource <GeoLocationCity>(); var result = await TaskEx.Run <GeoLocationCity>(() => { var query = PostalCodes.Where(item => item.PostalCode == postalCode).FirstOrDefault(); if (query == null) { return(GeoLocationCity.UnkownCity()); } return(query); }); return(result); }
public async Task <GeoLocationCity> LocationToPostalCodeAsync(GeoCoordinate location) { var tcs = new TaskCompletionSource <GeoLocationCity>(); var result = await TaskEx.Run <GeoLocationCity>(() => { var query = PostalCodes .OrderBy(item => item.Location.GetDistanceTo(location)) .FirstOrDefault(); if (query == null) { return(GeoLocationCity.UnkownCity()); } return(query); }); return(result); }