async void SendMessage() { string defaultMsg = "Help me"; string emergency = "Personal"; MessageDatabase mdb = new MessageDatabase(dbPath); var msg = await mdb.GetMessageAsync(emergency); if (msg.MessageTemplate == null) { msg.MessageTemplate = defaultMsg; } ContactDatabase cdb = new ContactDatabase(dbPath); var list = await cdb.GetContactsAsync(emergency); if (list.Count() > 0) { foreach (Contact contact in list) { DependencyService.Get <ISendSMS>().Send(contact.ContactNumber, msg.MessageTemplate); } } else { DependencyService.Get <IToast>().Toasts("hasData", "failed"); } }
public async void ShowData(string emergency) { MessageDatabase db = new MessageDatabase(dbPath); var Message = await db.GetMessageAsync(emergency); EmergencyName = Message.EmergencyName; MessageTemplate = Message.MessageTemplate; }
public async void OnSave() { MessageDatabase db = new MessageDatabase(dbPath); if (CheckFields()) { var SaveMessage = await db.GetMessageAsync(emergencyName); SaveMessage.MessageTemplate = messageTemplate; DependencyService.Get <IToast>().Toasts("updateMessage", db.UpdateMessage(SaveMessage)); } else { DependencyService.Get <IToast>().Toasts("updateMessage", "failed"); } await PopupNavigation.Instance.PopAsync(true); }
public async void InitMessage() { string[] emergencies = { "Police", "Medical", "Fire", "Personal" }; foreach (string value in emergencies) { MessageDatabase db = new MessageDatabase(dbPath); var _db = await db.GetMessageAsync(value); if (_db == null) { var Message = new Message() { EmergencyName = value, }; db.AddMessage(Message); } } }