public IActionResult ShowArticle(Guid id) { Article article = _articlesRepository.GetArticleById(id); IEnumerable <CommentProvider> comments = _articlesRepository.GetComments(id, 1, 5); var model = new ShowArticleViewModel { Text = article.Body, Title = article.Title, Comments = _mapper.Map <List <CommentItemViewModel> >(comments) }; return(View(model)); }
public async Task <IActionResult> ShowArticle(string title) { var articles = await _articleRep.FindAllAsync(false); Article article = articles.FirstOrDefault(n => n.Title == title); if (article == null || !article.IsPublish) { return(NotFound()); } article = await _articleRep.GetReferencePropertyAsync(article, n => n.Category); ShowArticleViewModel model = new ShowArticleViewModel(article); var comments = await _commentRep.FindByConditionAsync(n => n.ArticleId == article.Id, n => n.OrderByDescending(x => x.Date)); model.Comments = comments.Select(n => new CommentViewModel(n, in _convert)).ToList(); #region Update View article.View++; _articleRep.Update(article); await _uow.Commit(); #endregion return(View(model)); }