public AdminController() { articleService = new ArticleService(); accountService = new AccountService(); view = new EntitiesViewModels(); model = new RegisterViewModel(); }
public ActionResult DeleteComment(string id, string articleId) { EntitiesViewModels model = new EntitiesViewModels(); commentService.DeleteComment(id); model.Comments = commentService.GetComments(articleId); return(PartialView("AddComment", model)); }
public ActionResult ReadArticle(string id) { EntitiesViewModels model = new EntitiesViewModels(); model.Article = articleService.GetArticleByID(id); model.Comments = commentService.GetComments(id); return(View(model)); }
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)); }
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(); }
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)); }