public ActionResult CreateArticle(Article vm) { if (!ModelState.IsValid) { return View(vm); } Repository.Add(vm); Repository.Save(); return RedirectToAction("editarticle", new { id = vm.Id }); }
public ActionResult CreateArticle() { var vm = new Article { Date = DateTime.Today, IsVisible = true, IsOnFrontPage = true }; return View(vm); }
public ActionResult EditArticle(Article vm) { if (!ModelState.IsValid) { return View(vm); } UpdateModel(Repository.GetArticle(vm.Id)); Repository.Save(); return RedirectToAction("articles"); }
public ActionResult DeleteArticle(Article vm) { Repository.Delete(Repository.GetArticle(vm.Id)); Repository.Save(); return RedirectToAction("articles"); }
partial void DeleteArticle(Article instance);
partial void UpdateArticle(Article instance);
partial void InsertArticle(Article instance);
public void Delete(Article article) { _db.PersonToArticles.DeleteAllOnSubmit(article.PersonToArticles); _db.BookToArticles.DeleteAllOnSubmit(article.BookToArticles); _db.Articles.DeleteOnSubmit(article); }
public void Add(Article article) { _db.Articles.InsertOnSubmit(article); }