private void noteListView_KeyUp(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Delete) { bool?shouldPermenantlyDelete = null; foreach (var idx in noteListView.SelectedIndices) { var note = noteListView.Items[(int)idx] as Note; if (note.Notebook.Name == "Deleted") { if (shouldPermenantlyDelete == null) { shouldPermenantlyDelete = MessageBox.Show(this, "Items would be permenantly deleted - this is not undoable\n Are you sure?", "Permenantly Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes; if (!shouldPermenantlyDelete ?? false) { continue; } } } context.DeleteNote(note); ((IList)noteListView.DataSource).Remove(note); } context.SaveChangesAsync(); UpdateTagList(); UpdateNotebookList(); //UpdateNoteView(tagView.SelectedNode); } }
public OutgoingJsonData DeleteNote([FromBody] IncomingNoteRequest note) { using (var context = new NotesContext(Context, Configuration)) { context.DeleteNote(note); } return(new OutgoingJsonData { Data = "" }); }