public void DeleteNote(int id) { var note = GetNote(id); db.Remove(note); db.SaveChanges(); }
public void DeleteTodo(ToDo toDo) { using (var dbContext = new NotesContext()) { dbContext.Remove(toDo); dbContext.SaveChanges(); } }
public async Task DeleteTodoAsync(Todo todo) { using (var dbContext = new NotesContext()) { dbContext.Remove(todo); await dbContext.SaveChangesAsync().ConfigureAwait(false); } }
public async Task DeleteNote(Note note) { using (var dbContext = new NotesContext()) { dbContext.Remove(note); await dbContext.SaveChangesAsync(); } }
public void DeleteNote(Note note) { using (var dbContext = new NotesContext()) { dbContext.Remove(note); dbContext.SaveChanges(); } }
public async Task DeleteTodo(ToDo toDo) { using (var dbContext = new NotesContext()) { dbContext.Remove(toDo); await dbContext.SaveChangesAsync(); } }
public IActionResult Delete(long?id) { var note = _context.Notes.SingleOrDefault(m => m.Id == id); if (note == null) { return(NotFound()); } _context.Remove(note); _context.SaveChanges(); return(RedirectToAction("Index")); }
public void Remove(int id) { var note = Get(id); if (note == null) { return; } _notesContext.Remove(note); _notesContext.SaveChanges(); }
public bool Delete(int id) { var note = context.Notes .FirstOrDefault(note => note.Id == id); if (note == null) { return(false); } context.Remove(note); context.SaveChanges(); return(true); }
public void DeleteNote(int id) { var note = _context.Notes.Where(n => n.NoteID == id) .FirstOrDefault(); if (note != null) { _context.Remove(note); _context.SaveChanges(); } else { throw new Exception($"Cannot delete the note with id {id}"); } }
public bool Delete(Notes notes) { _notesContext.Remove(notes); _notesContext.SaveChanges(); return(true); }