public IHttpActionResult PutProduct(int id, Product product) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != product.Id) { return(BadRequest()); } db.MarkAsModified(product); try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!ProductExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult PutTypeProduct(int id, TypeProduct typeProduct) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != typeProduct.Id) { return(BadRequest()); } // db.Entry(typeProduct).State = EntityState.Modified; db.MarkAsModified(typeProduct); try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!TypeProductExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public int UpdateProducts(Product product) { productServiceContext.MarkAsModified(product); return(productServiceContext.SaveChanges()); }