示例#1
0
 //
 // GET: /Blog/Edit/5
 public ActionResult Edit(int id)
 {
     using (var db = new BlogDataEntities())
     {
         return View(db.Blogs.Find(id));
     }
 }
示例#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();
     }
 }
示例#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();
            }
        }
示例#4
0
 //
 // GET: /Blog/
 public ActionResult Index()
 {
     using (var db = new BlogDataEntities())
     {
         return View(db.Blogs.ToList());
     }
 }