Exemplo n.º 1
0
        public ActionResult Edit(Article article)
        {
            if (!ModelState.IsValid)
            {
                return View(article);
            }

            var currentArticle = _articleRepository.Find(article.Id);

            currentArticle.Key = Utilities.WebSafeMaker(article.Key);
            currentArticle.UpdatedOn = DateTime.UtcNow;
            currentArticle.CreatedOn = article.CreatedOn;
            currentArticle.Body = article.Body;
            currentArticle.Title = article.Title.Trim();
            currentArticle.MetaDescription = article.MetaDescription;

            _articleRepository.InsertOrUpdate(currentArticle);

            _articleRepository.Save();
            return RedirectToAction("Admin");
        }
Exemplo n.º 2
0
 public void InsertOrUpdate(Article article)
 {
     if (article.Id == default(int))
     {
         // New entity
         _context.Articles.Add(article);
     }
     else
     {
         // Existing entity
         _context.Entry(article).State = EntityState.Modified;
     }
 }
Exemplo n.º 3
0
        public ActionResult Create(Article article)
        {
            if (!ModelState.IsValid)
            {
                return View(article);
            }

            article.Key = Utilities.WebSafeMaker(article.Key);

            article.Title = article.Title.Trim();
            _articleRepository.InsertOrUpdate(article);
            _articleRepository.Save();
            return RedirectToAction("Admin");
        }