Пример #1
0
        public IActionResult GetReplies(int ideationId, [FromQuery(Name = "sortBy")] string sortBy = "recent")
        {
            List <IdeationReply> replies = _ideationManager.GetIdeationReplies(ideationId, 0, 999, sortBy).ToList();

            if (!replies.Any())
            {
                return(Ok());
            }

            var replyDtos = new List <IdeationReplyDTO>();

            replies.ForEach(r =>
            {
                var replyDto = new IdeationReplyDTO()
                {
                    IdeationReplyId  = r.IdeationReplyId,
                    IdeationId       = r.Ideation.IdeationId,
                    UpVotes          = r.Upvotes,
                    NumberOfComments = _ideationManager.CommentAmount(r.IdeationReplyId),
                    CreatedString    = r.Created.FormatParasableDate(),
                    Title            = r.Title,
                    UserDisplayName  = r.User.GetDisplayName()
                };

                replyDtos.Add(replyDto);
            });

            return(Ok(replyDtos));
        }