Ejemplo n.º 1
0
        public AppViewModel()
        {
            this.CouchDb.GetAll <Person>().ContinueWith((t) =>
            {
                if (t.Result != null)
                {
                    People = t.Result.ToObservable();
                }
                else
                {
                    People = new ObservableCollection <Person>();
                }
            });


            AddPerson = new CoreCommand(async(obj) => {
                var result = await this.CouchDb.AddOrUpdate <Person>(NewPerson);
                if (result != null)
                {
                    NewPerson = new Person();
                    People    = await CouchDb.GetAll <Person>().ToObservable();
                    Navigation.PushNonAwaited <PageTwo>();
                }
            });

            ViewPeople = new CoreCommand((obj) => {
                Navigation.PushNonAwaited <PageTwo>();
            });
        }
Ejemplo n.º 2
0
 public override void OnViewMessageReceived(string key, object obj)
 {
     if (key == CoreSettings.DeletePersonTag && obj != null)
     {
         var pk = (string)obj;
         Task.Run(async() =>
         {
             var result = await this.CouchDb.Delete <Person>(pk);
             if (result)
             {
                 People = await CouchDb.GetAll <Person>().ToObservable();
             }
         });
     }
 }