public void ConfirmNewNoteTitle(string newNoteTitle) { NewNoteClicked = false; string cd = Environment.CurrentDirectory; string filePath = cd + $@"\data\{User.Id}" + $@"\{SelectedNotebook.Id}" + $@"\{newNoteTitle}.rtf"; NoteModel note = Notes.ToList <NoteModel>().Find(n => n.Title == newNoteTitle); if (note == null) { try { DBDataAccessInsert.InsertNote(new NoteModel() { NotebookId = SelectedNotebook.Id, Title = newNoteTitle, CreatedTime = DateTime.Now, UpdatedTime = DateTime.Now, FileLocation = filePath }); Notes.Clear(); Notes = new BindableCollection <NoteModel>(DBDataAccessLoad.LoadNotebookNotes(SelectedNotebook.Id)); } catch (SQLiteException) { MessageBox.Show("Invalid Title"); } } else { MessageBox.Show("Note with this title already exists"); } }
public void DeleteNote() { int noteId = SelectedNote.Id; SelectedNote = null; DBDataAccessDelete.DeleteNote(noteId); if (SelectedNotebook != null) { Notes = new BindableCollection <NoteModel>(DBDataAccessLoad.LoadNotebookNotes(SelectedNotebook.Id)); } }
public void ConfirmNoteTitleRename(string newTitle) { RenameNoteClicked = false; SelectedNote.Title = newTitle; try { DBDataAccessUpdate.UpdateNote(SelectedNote); Notes = new BindableCollection <NoteModel>(DBDataAccessLoad.LoadNotebookNotes(SelectedNotebook.Id)); } catch (SQLiteException) { MessageBox.Show("Note title already in use"); } }