//Update existing contact public void UpdateContact(Contactos contact) { using (var dbConn = new SQLiteConnection(App.DB_PATH)) { var existingcontact = dbConn.Query<Contactos>("Select * from contactos where Id_contacto=" + contact.Id_contacto).FirstOrDefault(); if(existingcontact != null) { existingcontact.C_nome = contact.C_nome; existingcontact.C_telemovel = contact.C_telemovel; existingcontact.C_telcasa = contact.C_telcasa; existingcontact.C_teltrabalho = contact.C_teltrabalho; existingcontact.C_morada = contact.C_morada; existingcontact.C_email = contact.C_email; //existingcontact.C_foto = contact.C_foto; dbConn.RunInTransaction(() => { dbConn.Update(existingcontact); }); } } }//UPDATECONTACT
private void AppBarButton_Click(object sender, RoutedEventArgs e) { try { Contactos update = new Contactos(); update.C_nome = Unome.Text; update.C_telemovel = Utelemovel.Text; update.C_telcasa = Utelcasa.Text; update.C_teltrabalho = Uteltrabalho.Text; update.C_morada = Umorada.Text; update.C_email = Uemail.Text; update.Id_contacto = Id_selected; DB_Helper.UpdateContact(update); Frame.Navigate(typeof(MainPage)); } catch { } }
}//UPDATECONTACT //Insert the new contact public void InsertContact(Contactos newcontact) { using (var dbConn = new SQLiteConnection(App.DB_PATH)) { dbConn.RunInTransaction(() => { dbConn.Insert(newcontact); }); } }//NEWCONTACT
public ContactsDataModel(Contactos model) { _model = model; LoadImage(); }