Пример #1
0
        public IdeaDto GetIdea(int ideaId, string userId)
        {
            try
            {
                var idea = _ideationManager.GetIdea(ideaId);
                if (idea == null)
                {
                    throw new ArgumentException("Idea not found", "ideaId");
                }

                var dto = _mapper.Map <IdeaDto>(idea);

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

                dto.Comments = _commentsHelper.GetCommentsForIdea(idea.IdeaId, userId);

                return(dto);
            }
            catch (Exception e)
            {
                throw new Exception($"Something went wrong in getting the comment: {e.Message}.");
            }
        }
Пример #2
0
 public IActionResult GetCommentsForIdea(int id, [FromQuery] string userId)
 {
     return(Ok(_commentsHelper.GetCommentsForIdea(id, userId)));
 }