예제 #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());
     }
 }