public IHttpActionResult PutPlayer(int id, Player player) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != player.Id) { return(BadRequest()); } db.Entry(player).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!PlayerExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IActionResult> PutUser(int id, User user) { if (id != user.Id) { return(BadRequest()); } _context.Entry(user).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!UserExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }