public async void ShowData(string emergency, int id) { ContactDatabase db = new ContactDatabase(dbPath); var Contact = await db.GetContactAsync(emergency, id); EmergencyName = Contact.EmergencyName; ContactName = Contact.ContactName; ContactNumber = Contact.ContactNumber; //var _db = App.EmergencyDatabase.GetEmergency(emergency); //EmergencyImage = emergency.ToLower() + ".png"; //EmergencyName = _db.EmergencyName; //ContactName = _db.ContactName; //ContactNumber = _db.ContactNumber; //MessageTemplate = _db.MessageTemplate; }
public async void OnAdd(object function) { ContactDatabase db = new ContactDatabase(dbPath); if (CheckFields()) { switch (function) { case "Add": var Contact = new Contact() { EmergencyName = emergencyName, ContactName = contactName, ContactNumber = contactNumber }; // DependencyService.Get<IToast>().Toasts("custom",emergency); DependencyService.Get <IToast>().Toasts("addContact", db.AddContact(Contact)); ContactName = ""; ContactNumber = ""; MessagingCenter.Send <App>((App)Application.Current, "OnContactAdded"); break; case "Update": var UpdateContact = await db.GetContactAsync(emergencyName, contactId); UpdateContact.ContactName = contactName; UpdateContact.ContactNumber = contactNumber; DependencyService.Get <IToast>().Toasts("updateContact", db.UpdateContact(UpdateContact)); MessagingCenter.Send <App>((App)Application.Current, "OnContactUpdated"); await PopupNavigation.Instance.PopAsync(true); break; } } else { DependencyService.Get <IToast>().Toasts("addContact", "failed"); } }