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