public WeatherServicesModel() { _dbDriver = App.Container.GetInstance <IDatabaseProvider>(); Services = new ObservableCollection <WeatherModel>(); LoadItemsCommand = new Command(async() => await ExecuteLoadItemsCommand()); MessagingCenter.Subscribe <NewWeatherLocationPage, WeatherModel>(this, "AddWeatherLocation", async(obj, item) => { var newModel = new WeatherLocations(item); int id = await _dbDriver.AddOrUpdateAsync(newModel); newModel.Id = id; Services.Add(new WeatherModel(newModel)); new Command(async() => await ExecuteLoadItemsCommand()).Execute(null); }); }
public WeatherModel(WeatherLocations loc) { Id = loc.Id; Name = loc.Name; Enabled = loc.Enabled == 1; LocationProvider = loc.LocationCode; if (loc.LocationCode == WeatherSettings.Location.CityCountry) { City = loc.City; CountryCode = loc.Country; } else if (loc.LocationCode == WeatherSettings.Location.Coordinates) { Latitude = loc.Latitude; Longitude = loc.Longitude; } else if (loc.LocationCode == WeatherSettings.Location.ZIP) { ZipCode = loc.ZipCode; } }
private void BootstrapWeatherDoc() { var current = weatherDocStore.GetWeatherLocations(); if (current == null) { var defaultLocations = new WeatherLocations { Locations = new List <WeatherLocation> { new WeatherLocation { Name = "Bothell, WA", Identifier = "home", Latitude = 47.7610, Longitude = 122.2056 } } }; weatherDocStore.UpdateLocations(defaultLocations); Logger.Info("Created Weather Locations Document"); } }
public void UpdateLocations(WeatherLocations defaultLocations) { Upsert(defaultLocations); }