示例#1
0
        public ViewResult Comments(int page = 1)
        {
            ViewBag.Title = Resources.ListMyComments;
            IList <Comment> Comments = repoComment.Comments(userID: user.UserID, page: page, take: PageSize);
            IList <CommentWithArticleViewModel> commentWithArticleViewModel = new List <CommentWithArticleViewModel>();

            foreach (var comment in Comments)
            {
                commentWithArticleViewModel.Add(new CommentWithArticleViewModel
                {
                    Comment = comment,
                    Article = repoArticle.Article(commentID: comment.CommentID)
                });
            }
            CommentsWithArticlesViewModel CommentsViewModel = new CommentsWithArticlesViewModel
            {
                CommentWithArticleViewModel = commentWithArticleViewModel,
                ContentExternalUrl          = repoConfig.Get(ConfigurationKeyStatic.CONTENT_EXTERNAL_URL),
                PagingInfo = new PagingInfo
                {
                    CurrentPage  = page,
                    ItemsPerPage = PageSize,
                    TotalItems   = repoComment.Comments(userID: user.UserID).Count()
                }
            };

            return(View(CommentsViewModel));
        }
示例#2
0
        public async Task <IActionResult> GetComments([FromRoute] Guid eventId)
        {
            try
            {
                var commnets = (await _commentRepo.Comments(eventId)).Select(c => new CommentDetailDTO()
                {
                    CommentId = c.Id,
                    Content   = c.Content,
                    CreatedAt = c.CreatedAt,
                    User      = new UserInfoDTO()
                    {
                        UserId    = c.User.Id,
                        FirstName = c.User.FirstName,
                        LastName  = c.User.LastName,
                        PhotoUrl  = c.User.Photo
                    }
                }).ToList();

                if (commnets.IsNullOrEmpty())
                {
                    return(NotFound("Kayıt bulunamadı."));
                }

                return(Ok(commnets));
            }
            catch (Exception ex)
            {
                _logHelper.Log("CommentsController", 500, "GetComments", ex.Message);
                return(null);
            }
        }
示例#3
0
        public ViewResult Comments(int page = 1)
        {
            ViewBag.Title = Resources.ListOfComments;
            IList <Comment>   Comments          = repoComment.Comments(page: page, take: PageSize, enabled: false);
            CommentsViewModel commentsViewModel = new CommentsViewModel
            {
                PagingInfo = new PagingInfo
                {
                    CurrentPage  = page,
                    ItemsPerPage = PageSize,
                    TotalItems   = repoComment.Comments(enabled: false).Count()
                }
            };

            return(View(commentsViewModel));
        }
 public async Task <IEnumerable <Comment> > Comments(int Id)
 {
     return(commentRepository.Comments(Id));
 }
示例#5
0
        public async Task <IActionResult> GetCommentsAnalyse([FromRoute] Guid eventId)
        {
            var model = new List <CommentAnalyticsDTO>();

            var comments = await _commentRepo.Comments(eventId);

            if (!comments.IsNullOrEmpty())
            {
                var inputs = new List <Input>();
                foreach (var comment in comments)
                {
                    inputs.Add(new Input()
                    {
                        Id   = comment.Id.ToString(),
                        Text = comment.Content
                    });
                    model.Add(new CommentAnalyticsDTO()
                    {
                        CommentId = comment.Id,
                        Content   = comment.Content,
                        CreatedAt = comment.CreatedAt
                    });
                }

                TextAnalytics _textAnalytics = new TextAnalytics();

                var multiLanguageInputs = new List <MultiLanguageInput>();
                var languageResult      = _textAnalytics.DetectLanguage(inputs);
                if (languageResult != null)
                {
                    for (int i = 0; i < languageResult.Documents.Count; i++)
                    {
                        foreach (var item in model)
                        {
                            if (item.CommentId.ToString() == languageResult.Documents[i].Id)
                            {
                                item.Language     = languageResult.Documents[i].DetectedLanguages[0].Name;
                                item.LanguageCode = languageResult.Documents[i].DetectedLanguages[0].Iso6391Name;
                            }
                        }

                        multiLanguageInputs.Add(new MultiLanguageInput()
                        {
                            Id       = model[i].CommentId.ToString(),
                            Language = model[i].LanguageCode,
                            Text     = model[i].Content
                        });
                    }

                    var keyPhrases = _textAnalytics.GetKeyPhrases(multiLanguageInputs);
                    if (keyPhrases != null)
                    {
                        for (int i = 0; i < keyPhrases.Documents.Count; i++)
                        {
                            foreach (var item in model)
                            {
                                if (item.CommentId.ToString() == keyPhrases.Documents[i].Id)
                                {
                                    item.KeyPhrases = keyPhrases.Documents[i].KeyPhrases.ToList();
                                }
                            }
                        }
                    }

                    var sentimentResult = _textAnalytics.GetSentiment(multiLanguageInputs);
                    if (sentimentResult != null)
                    {
                        for (int i = 0; i < sentimentResult.Documents.Count; i++)
                        {
                            foreach (var item in model)
                            {
                                if (item.CommentId.ToString() == sentimentResult.Documents[i].Id)
                                {
                                    item.Sentiment = sentimentResult.Documents[i].Score.ToString();
                                }
                            }
                        }
                    }
                }
            }

            return(Ok(model));
        }