Example #1
0
 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);
 }
Example #2
0
 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));
 }
Example #3
0
        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);
        }
Example #4
0
        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);
        }