Пример #1
0
        public static CommentDTO ConvertCommentToDTO(Comment comment)
        {
            CommentDTO newDto = new CommentDTO
            {
                Id               = comment.Id,
                Description      = comment.Description,
                CreationDate     = comment.CreationDate.ToString("dd.mm.yyyy"),
                NumberOfLikes    = comment.NumberOfLikes,
                NumberOfDislikes = comment.NumberOfDislikes,
                User             = UserForVideoComment.ConvertUserForVideoComment(comment.User),
                Video            = VideoForUser.ConvertVideo(comment.Video)
            };

            return(newDto);
        }
Пример #2
0
        public static List <CommentDTO> ConvertCommenstToDTO(IEnumerable <Comment> comments)
        {
            List <CommentDTO> commentsDTO = new List <CommentDTO>();

            foreach (var comment in comments)
            {
                CommentDTO newDto = new CommentDTO
                {
                    Id               = comment.Id,
                    Description      = comment.Description,
                    CreationDate     = comment.CreationDate.ToString("dd.mm.yyyy"),
                    NumberOfLikes    = comment.NumberOfLikes,
                    NumberOfDislikes = comment.NumberOfDislikes,
                    User             = UserForVideoComment.ConvertUserForVideoComment(comment.User),
                    Video            = VideoForUser.ConvertVideo(comment.Video)
                };

                commentsDTO.Add(newDto);
            }

            return(commentsDTO);
        }