public bool UpdateProduct(int id, Product product) { try { db.Entry(product).State = EntityState.Modified; db.SaveChanges(); return(true); } catch (Exception) { return(false); } }
public IHttpActionResult PutProductsTable(int id, ProductsTable productsTable) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != productsTable.Pid) { return(BadRequest()); } db.Entry(productsTable).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!ProductsTableExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public ActionResult Edit([Bind(Include = "ID_PROV,NOMBRE,DIRECCION,NUM_TELF")] PROVEEDOR pROVEEDOR) { if (ModelState.IsValid) { db.Entry(pROVEEDOR).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(pROVEEDOR)); }
public ActionResult Edit([Bind(Include = "ID,NOMBRE,DESCRIPCION,FECHA_VENC,ID_PROVEEDOR")] Producto producto) { if (ModelState.IsValid) { db.Entry(producto).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ID_PROVEEDOR = new SelectList(db.PROVEEDORs, "ID_PROV", "NOMBRE", producto.ID_PROVEEDOR); return(View(producto)); }
public IHttpActionResult UpdateEmployee(int id, [FromBody] Product us) { if (ModelState.IsValid) { var UserExist = dbContext.Products.Count(c => c.ProductID == id) > 0; if (UserExist) { dbContext.Entry(us).State = EntityState.Modified; dbContext.SaveChanges(); return(Ok()); } else { return(NotFound()); } } else { return(BadRequest()); } }
public void Update(TEntity obj) { table.Attach(obj); db.Entry(obj).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); }