Exemple #1
0
        public ActionResult Create([Bind(Include = "Id,Title,Content")] Snippet snippet)
        {
            if (ModelState.IsValid)
            {
                db.Snippets.Add(snippet);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(snippet));
        }
Exemple #2
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);
 }