public IHttpActionResult PutStock(int id, Stock stock) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != stock.ID) { return(BadRequest()); } db.Entry(stock).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!StockExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }