public async Task <IHttpActionResult> PutPhone(int id, Phone phone) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != phone.PhoneId) { return(BadRequest()); } db.Entry(phone).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PhoneExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }