private async Task <Address> UpdateAddressWithPlaceDetail(Address value) { if ((value != null) && (value.AddressType == "place")) { var place = await _placesService.GetPlaceDetail(value.FriendlyName, value.PlaceId); return(place); } if ((value != null) && (value.AddressType == "postal") && (value.PlaceId.HasValueTrimmed())) { // address coming from Google with no detail var place = await _geocodingService.GetPlaceDetail(value.PlaceId); return(place); } if ((value != null) && (value.AddressType == "craftyclicks")) { var geoLoc = await _geolocService.SearchAddress(value.FullAddress, value.Latitude, value.Longitude); if (geoLoc.Any()) { return(geoLoc.First()); } } return(value); }
private async Task <Address> SearchAddressForCoordinate(Position p) { _loadingAddressSubject.OnNext(true); var accountAddress = await _accountService .FindInAccountAddresses(p.Latitude, p.Longitude) .ConfigureAwait(false); if (accountAddress != null) { _loadingAddressSubject.OnNext(false); return(accountAddress); } var address = await Task.Run(() => _geolocService.SearchAddress(p.Latitude, p.Longitude)); if (address.Any()) { _loadingAddressSubject.OnNext(false); return(address[0]); } _loadingAddressSubject.OnNext(false); return(new Address { Latitude = p.Latitude, Longitude = p.Longitude }); }