private void AddSubscriptionBase() { MessagingCenter.Subscribe <ISubcriptor, Contact>(this, "SaveContact", ((sender, contact) => { if (contact.Id == Guid.Empty) { contact.Id = Guid.NewGuid(); Contacts.Add(contact); monkeyManager.SaveMokey <Contact>(Contacts, "contacts"); } else { var contactIndex = Contacts.FindIndex(e => e.Id == contact.Id); if (contactIndex == -1) { App.Current.MainPage.DisplayAlert("Error: editing contact", "Error editing your contact, try again", "OK"); } else { Contacts[contactIndex] = contact; monkeyManager.SaveMokey <Contact>(Contacts, "contacts"); } } MessagingCenter.Send <ISubcriptor, ObservableCollection <Contact> >(this, "ChangeContacts", Contacts); SelectedContact = new Contact(); })); }
private void CreateSubscriptions() { MessagingCenter.Subscribe <ISubcriptor, ObservableCollection <User> >(this, "ChangeUsers", (sender, users) => { Users = users; monkeyManager.SaveMokey <User>(users, "users"); }); }