コード例 #1
0
        public void DeleteNote(int id)
        {
            var note = GetNote(id);

            db.Remove(note);
            db.SaveChanges();
        }
コード例 #2
0
 public void DeleteTodo(ToDo toDo)
 {
     using (var dbContext = new NotesContext())
     {
         dbContext.Remove(toDo);
         dbContext.SaveChanges();
     }
 }
コード例 #3
0
 public async Task DeleteTodoAsync(Todo todo)
 {
     using (var dbContext = new NotesContext())
     {
         dbContext.Remove(todo);
         await dbContext.SaveChangesAsync().ConfigureAwait(false);
     }
 }
コード例 #4
0
 public async Task DeleteNote(Note note)
 {
     using (var dbContext = new NotesContext())
     {
         dbContext.Remove(note);
         await dbContext.SaveChangesAsync();
     }
 }
コード例 #5
0
 public void DeleteNote(Note note)
 {
     using (var dbContext = new NotesContext())
     {
         dbContext.Remove(note);
         dbContext.SaveChanges();
     }
 }
コード例 #6
0
 public async Task DeleteTodo(ToDo toDo)
 {
     using (var dbContext = new NotesContext())
     {
         dbContext.Remove(toDo);
         await dbContext.SaveChangesAsync();
     }
 }
コード例 #7
0
        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"));
        }
コード例 #8
0
        public void Remove(int id)
        {
            var note = Get(id);

            if (note == null)
            {
                return;
            }

            _notesContext.Remove(note);

            _notesContext.SaveChanges();
        }
コード例 #9
0
        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);
        }
コード例 #10
0
        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}");
            }
        }
コード例 #11
0
 public bool Delete(Notes notes)
 {
     _notesContext.Remove(notes);
     _notesContext.SaveChanges();
     return(true);
 }