Beispiel #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);
     });
 }
Beispiel #2
0
        private async Task SendOrSaveChanges(ConfigurationEventArgs args)
        {
            if (args == null)
            {
                return;
            }

            if (args.Configuration != null)
            {
                _msgService.SendConfig(args.Configuration);
            }

            else if (args.Entity != null)
            {
                await _dbService.AddOrUpdateAsync(args.Entity);
            }
        }