public async Task <IActionResult> PutTodoItem(long id, TodoItemDTO todoItemDTO) { if (id != todoItemDTO.Id) { return(BadRequest()); } _context.Entry(todoItemDTO).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TodoItemExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public void Update(Command entity) { using (var ctx = new DatabContext()) { ctx.Commands.Attach(entity); ctx.Entry(entity).State = EntityState.Modified; ctx.SaveChanges(); } }
public virtual void Update(T entity) { dbset.Attach(entity); dataContext.Entry(entity).State = EntityState.Modified; }