public IHttpActionResult PutUser([FromBody] User user) { var currentId = UserUtilities.GetCurrentUserId(User); //var currentId = id; if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (currentId != user.UserId) { return(Unauthorized()); } db.Entry(user).State = System.Data.Entity.EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!UserExists(currentId)) { return(NotFound()); } else { throw; } } return(Ok(user)); }