public 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 { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!UserExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult PutOrderDetail(int id, OrderDetail orderDetail) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != orderDetail.OrderID) { return(BadRequest()); } db.Entry(orderDetail).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!OrderDetailExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public void updateModel(T Model) { table.Attach(Model); context.Entry(Model).State = EntityState.Modified; }