public EntityEntry <TEntity> Update(TEntity entity) { AttachIfNot(entity); var ent = _context.Entry(entity); ent.State = EntityState.Modified; return(ent); }
public bool DeleteCategories(Category category) { var context = new APPContext(); context.Entry(category).State = System.Data.Entity.EntityState.Deleted; return(context.SaveChanges() > 0); }
public async Task <IActionResult> PutItem(int id, Item item) { if (id != item.Id) { return(BadRequest()); } _context.Entry(item).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ItemExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public void Update(UserModel entity) { var oriUser = _appContext.Users.Single(x => x.Id == entity.Id); _appContext.Entry(oriUser).CurrentValues.SetValues(entity); _appContext.SaveChanges(); }
public TEntity Update(TEntity entity) { AttachIfNot(entity); _context.Entry(entity).State = EntityState.Modified; return entity; }