private Data.Shared.Models.Location GetLocationFromMetadata(IDictionary <string, string> metadata) { var location = new Data.Shared.Models.Location(); var hasValues = false; if (metadata.Count > 0) { if (metadata.TryGetValue(Constants.Latitude, out var latitude)) { if (!string.IsNullOrEmpty(latitude)) { if (double.TryParse(latitude, out var latValue)) { location.Latitude = latValue; hasValues = true; } } } if (metadata.TryGetValue(Constants.Longitude, out var longitude)) { if (!string.IsNullOrEmpty(longitude)) { if (double.TryParse(longitude, out var longValue)) { location.Longitude = longValue; hasValues = true; } } } if (metadata.TryGetValue(Constants.Altitude, out var altitude)) { if (!string.IsNullOrEmpty(altitude)) { if (double.TryParse(altitude, out var altValue)) { location.Altitude = altValue; hasValues = true; } } } } return(hasValues ? location : null); }
public async Task <Data.Shared.Models.Location> AddOrUpdateLocationAsync(Data.Shared.Models.Location location) { var locationResult = await _locationRepository.AddOrUpdateAsync(l => l.Id == location.LocationId, location.AsStore()); return(locationResult.AsModel()); }