public ActionResult Delete(int id, Article article) { var articleInDb = _articleRepository.GetById(id); if (articleInDb != null) { _articleRepository.Remove(articleInDb); UnitOfWork.Save(); } return RedirectToAction("Index"); }
public ActionResult Create(Article article) { if (ModelState.IsValid) { article.PublishedOn = DateTime.Now; UpdateModel<Article>(article); _articleRepository.Add(article); UnitOfWork.Save(); return RedirectToAction("Index"); } return View(article); }
public ActionResult Create(string topic) { Article article = new Article(); article.Topic = topic; return View(article); }
public ActionResult Edit(int id, Article article) { var articleInDb = _articleRepository.GetById(id); articleInDb.PublishedOn = DateTime.Now; articleInDb.Body = string.IsNullOrEmpty(article.Body) ? "" : article.Body.Replace("<", "<").Replace(">", ">").Replace("&", "&"); if (TryUpdateModel(articleInDb)) { UnitOfWork.Save(); return RedirectToAction("Index"); } return View(article); }