public ActionResult Edit([Bind(Include = "id,name,note")] Category category) { if (ModelState.IsValid) { db.Entry(category).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(category)); }
public ActionResult Edit([Bind(Include = "id,code,name,sort_name,note,category_id")] Product product) { if (ModelState.IsValid) { db.Entry(product).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.category_id = new SelectList(db.Categories, "id", "name", product.category_id); return(View(product)); }
public async Task <int> UpdateAsync(TEntity entity) { if (entity == null) { throw new ArgumentNullException(nameof(entity)); } try { EF.Entry(entity).State = EntityState.Modified; this.Table.Update(entity); return(await EF.SaveChangesAsync()); } catch (DbUpdateException ex) { throw new Exception(this.GetFullErrorTextAndRollback(ex), ex); } }