Ejemplo n.º 1
0
        public CommentDto GetComment(int id, string userId)
        {
            try
            {
                var comment = _ideationManager.GetComment(id);
                if (comment == null)
                {
                    throw new ArgumentException("Comment not found", "id");
                }

                var dto = _mapper.Map <CommentDto>(comment);

                var vote = _userManager.GetVoteForComment(id, userId);
                if (vote != null)
                {
                    dto.UserVoteValue = vote.Value;
                }

                return(dto);
            }
            catch (Exception e)
            {
                throw new Exception($"Something went wrong in getting the comment: {e.Message}.");
            }
        }
Ejemplo n.º 2
0
        public IActionResult ReportComment(ReportDTO reportDto)
        {
            Comment comment     = _ideationManager.GetComment(reportDto.CommentId);
            User    user        = _usermanager.GetUserAsync(User).Result;
            Report  FoundReport = _ideationManager.FindReport(user, comment);

            if (FoundReport != null)
            {
                return(Ok());
            }
            Report report = new Report()
            {
                Reason          = reportDto.Reason,
                ReportedComment = comment,
                User            = user
            };

            _ideationManager.ReportComment(report);
            _unitOfWorkManager.Save();

            return(Ok(report.ReportId));
        }