public int SaveStanza(StanzaInfo stanza)
 {
     lock (locker)
     {
         if (stanza.id != 0)
         {
             database.Update(stanza);
             return(stanza.id);
         }
         else
         {
             return(database.Insert(stanza));
         }
     }
 }
Exemple #2
0
        private void SaveStanzaButton_Clicked(object sender, EventArgs e)
        {
            //set variables to current values
            this.StanzaName   = StanzaNameEntry.Text;
            this.stanza_notes = NotesEditor.Text;
            this.line_1       = line1_entry.Text;
            this.line_2       = line2_entry.Text;
            this.line_3       = line3_entry.Text;
            this.line_4       = line4_entry.Text;

            this.chord_1a = chord1a_entry.Text;
            this.chord_1b = chord1b_entry.Text;
            this.chord_1c = chord1c_entry.Text;
            this.chord_2a = chord2a_entry.Text;
            this.chord_2b = chord2b_entry.Text;
            this.chord_2c = chord2c_entry.Text;
            this.chord_3a = chord3a_entry.Text;
            this.chord_3b = chord3b_entry.Text;
            this.chord_3c = chord3c_entry.Text;
            this.chord_4a = chord4a_entry.Text;
            this.chord_4b = chord4b_entry.Text;
            this.chord_4c = chord4c_entry.Text;



            StanzaInfo stanza = new StanzaInfo(this.StanzaName, this.SongName, this.SetName, this.SetDescription, this.song_notes, this.verified_username, this.verified_password, this.stanza_notes, this.line_1, this.line_2,
                                               this.line_3, this.line_4, this.chord_1a, this.chord_1b, this.chord_1c, this.chord_2a, this.chord_2b, this.chord_2c,
                                               this.chord_3a, this.chord_3b, this.chord_3c, this.chord_4a, this.chord_4b, this.chord_4c);

            using (SQLiteConnection conn = new SQLiteConnection(_dbPath))
            {
                conn.CreateTable <StanzaInfo>();               //creates table to read from it?
                var data = conn.Table <StanzaInfo>().ToList(); //everything is in contacts at this point
                foreach (StanzaInfo s in data)
                {
                    if (s.username == stanza.username && s.password == stanza.password && s.SetName == stanza.SetName && s.SongName == stanza.SongName && s.StanzaName == stanza.StanzaName)
                    {
                        App.UserDatabase.DeleteStanza(s.id);
                    }
                }
                App.UserDatabase.SaveStanza(stanza);
                Navigation.PopAsync();
                Navigation.PushAsync(new SongPage(this.SongName, this.SetName, this.SetDescription, this.verified_username, this.verified_password, this.song_notes));
            }
        }