Пример #1
0
        public async Task <List <CommentDTO> > GetPage(long postId, string userId)
        {
            var dbcomments = await commentManager.GetPage(postId);

            var comments = mapper.Map <List <CommentDTO> >(dbcomments);

            if (!string.IsNullOrEmpty(userId))
            {
                var userVotes = commentManager.GetVotes(dbcomments, userId);
                foreach (var vote in userVotes)
                {
                    comments[userVotes.IndexOf(vote)].UserVote = vote.Value;
                }
            }
            return(comments);
        }