protected bool Update(T obj) { if (ModelState.IsValid) { db.Entry(obj).State = System.Data.Entity.EntityState.Modified; try { db.SaveChanges(); return(true); } catch { return(false); } } return(false); }
public ActionResult Edit([Bind(Include = "Id,Title,Content")] Snippet snippet) { if (ModelState.IsValid) { db.Entry(snippet).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(snippet)); }
public ChangeEvent Delete(BootstrapContext db, int?id) { ChangeEvent changeEvent = Get(db, id); if (changeEvent != null) { changeEvent.DeletedOn = DateTime.UtcNow; changeEvent.DeletedByUserIdCode = this._userIdCode; db.Entry(changeEvent).State = System.Data.Entity.EntityState.Modified; } return(changeEvent); }
public ChangeEvent Update(BootstrapContext db, int?changeEventId) { ChangeEvent changeEvent = Get(db, changeEventId); if (changeEvent == null) { changeEvent = Create(db); } else { changeEvent.UpdatedOn = DateTime.UtcNow; changeEvent.UpdatedByUserIdCode = this._userIdCode; db.Entry(changeEvent).State = System.Data.Entity.EntityState.Modified; } return(changeEvent); }