public SettingsViewModel(ISettings settings, Keys keys, IGeoCoder locator, ICongress congress, INavigationService2 navigationService) : base(navigationService) { _settings = settings; _congress = congress; _zipSearchVm = new ZipCodeSearchViewModel(navigationService); _geoVM = new GeoLocationViewModel(keys, navigationService); _locator = locator; _location = _settings.Location; if (_location != null) { _zipcode = _location.ZipCode; } _district = new RemoteResult<dynamic>(() => _congress.FindFirstDistrict(_location.Lat, _location.Long), () => RaisePropertiesChanged("District"), new ExpandoObject()); }
private async Task SetLocationFromZip() { if (_zipSearchVm.IsValidZip(_zipcode)) { var coord = await _locator.GetCoordinate("", "", "", _zipcode, "US"); _geoVM.SetLocation(coord.Item1, coord.Item2); _location = new Location() { ZipCode = _zipcode, Lat = coord.Item1, Long = coord.Item2 }; _settings.Location = _location; } _district.Reset(); }