Ejemplo n.º 1
0
        public bool SaveArticle(NewsDTO article)
        {
            try
            {
                if (article.Id == -1)
                {
                    var newArticle = Mapper.Map<News>(article);
                    newArticle.CreatedTime = DateTime.UtcNow;
                    uOW.NewsRepo.Insert(newArticle);
                }
                else
                {
                    var articleDb = uOW.NewsRepo.GetByID(article.Id);
                    articleDb.Title = article.Title;
                    articleDb.Article = article.Article;
                }

                uOW.Save();
                return true;
            }
            catch (Exception ex)
            {
                return false;
            }
        }
Ejemplo n.º 2
0
 public bool SaveArticle(int id, string title, string article)
 {
     var newArticle = new NewsDTO();
     newArticle.Id = id;
     newArticle.Title = title;
     newArticle.Article = article;
     return NewsManager.SaveArticle(newArticle);
 }
Ejemplo n.º 3
0
 public ActionResult Edit(int id)
 {
     if (id == -1)
     {
         var emptyArticle = new NewsDTO();
         emptyArticle.Id = -1;
         return View(emptyArticle);
     } else
     {
         return View(NewsManager.GetOneArticle(id));
     }
 }