public void Update(Shop shop) { if (Get(shop.Id) == null) { return; } db.Entry(shop).State = EntityState.Modified; db.SaveChanges(); }
public IHttpActionResult PutShop(int id, Shop shop) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != shop.ShopId) { return(BadRequest()); } db.Entry(shop).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!ShopExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult PutProduct(int id, Product product) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != product.ProductId) { return(BadRequest()); } db.Entry(product).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!ProductExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public void Update(Product product) { if (Get(product.Id) == null) { return; } db.Entry(product).State = EntityState.Modified; db.SaveChanges(); }
public void Update(TModel model) { db.Entry <TModel>(model).State = EntityState.Modified; db.SaveChanges(); }