コード例 #1
0
 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);
     });
 }
コード例 #2
0
 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;
     }
 }
コード例 #3
0
        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");
            }
        }
コード例 #4
0
ファイル: WeatherDataService.cs プロジェクト: charlesj/Apollo
 public void UpdateLocations(WeatherLocations defaultLocations)
 {
     Upsert(defaultLocations);
 }