Esempio n. 1
0
 public AdminController()
 {
     articleService = new ArticleService();
     accountService = new AccountService();
     view           = new EntitiesViewModels();
     model          = new RegisterViewModel();
 }
Esempio n. 2
0
        public ActionResult DeleteComment(string id, string articleId)
        {
            EntitiesViewModels model = new EntitiesViewModels();

            commentService.DeleteComment(id);
            model.Comments = commentService.GetComments(articleId);
            return(PartialView("AddComment", model));
        }
Esempio n. 3
0
        public ActionResult ReadArticle(string id)
        {
            EntitiesViewModels model = new EntitiesViewModels();

            model.Article  = articleService.GetArticleByID(id);
            model.Comments = commentService.GetComments(id);
            return(View(model));
        }
Esempio n. 4
0
 public ActionResult AddComment(EntitiesViewModels model)
 {
     if (model.UserName != null && model.Text != null)
     {
         commentService.AddNewComment(model);
     }
     model.Comments = commentService.GetComments(model.Article.Id);
     return(PartialView(model));
 }
Esempio n. 5
0
        public void AddNewComment(EntitiesViewModels model)
        {
            Comment comment = new Comment();

            comment.UserName = model.UserName;
            comment.Text     = model.Text;
            comment.Article  = articleRepository.GetByID(model.Article.Id);
            commentRepository.Insert(comment);
            commentRepository.Save();
        }
Esempio n. 6
0
        public ActionResult Index()
        {
            List <Article>            articleList          = articleService.GetArticles();
            List <EntitiesViewModels> articleViewModelList = new List <EntitiesViewModels>();

            foreach (var article in articleList)
            {
                EntitiesViewModels model = new EntitiesViewModels {
                    Article = article
                };
                articleViewModelList.Add(model);
            }
            return(View(articleViewModelList));
        }