public async Task <IHttpActionResult> PutUser(int id, User user) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != user.Id) { return(BadRequest()); } db.Entry(user).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!UserExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public virtual void Update(TEntity obj) { Db.Entry(obj).State = EntityState.Modified; Save(); }