Esempio n. 1
0
 //
 // GET: /Blog/Edit/5
 public ActionResult Edit(int id)
 {
     using (var db = new BlogDataEntities())
     {
         return View(db.Blogs.Find(id));
     }
 }
Esempio n. 2
0
 public ActionResult Delete(int id, Blog blog)
 {
     try
     {
         using (var db = new BlogDataEntities())
         {
             db.Entry(blog).State = System.Data.EntityState.Deleted;
             db.SaveChanges();
         }
         return RedirectToAction("Index");
     }
     catch
     {
         return View();
     }
 }
Esempio n. 3
0
        public ActionResult Create(Blog blog)
        {
            try
            {
                using (var db = new BlogDataEntities())
                {
                    db.Blogs.Add(blog);
                    db.SaveChanges();
                }

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
Esempio n. 4
0
 //
 // GET: /Blog/
 public ActionResult Index()
 {
     using (var db = new BlogDataEntities())
     {
         return View(db.Blogs.ToList());
     }
 }