示例#1
0
 public ActionResult Delete(int id, Article article)
 {
     try
     {
         using (var db = new ArticleEntities())
         {
             db.Entry(article).State = EntityState.Deleted;
             db.SaveChanges();
             return RedirectToAction("Index");
         }
     }
     catch
     {
         return View();
     }
 }
示例#2
0
 public ActionResult Create(Article article)
 {
     try
     {
         using (var db = new ArticleEntities())
         {
             article.CreateDate = DateTime.Now;
             article.EditDate = DateTime.Now;
             article.EditUser = User.Identity.Name;
             article.Text = HttpUtility.UrlDecode(article.Text, System.Text.Encoding.Default);
             db.Articles.Add(article);
             db.SaveChanges();
         }
         return RedirectToAction("Index");
     }
     catch
     {
         return View();
     }
 }
示例#3
0
 public ActionResult Edit(int id, Article article)
 {
     try
     {
         using (var db = new ArticleEntities())
         {
             article.EditDate = DateTime.Now;
             article.EditUser = User.Identity.Name;
             article.Text = HttpUtility.UrlDecode(article.Text, System.Text.Encoding.Default);
             db.Entry(article).State = EntityState.Modified;
             db.SaveChanges();
             return RedirectToAction("Index");
         }
     }
     catch
     {
         return View();
     }
 }