Exemple #1
0
        public static List <VideoForUser> ConvertVideoToDTO(IEnumerable <Video> video)
        {
            List <VideoForUser> videos = new List <VideoForUser>();

            foreach (var v in video)
            {
                VideoForUser newVDTO = new VideoForUser
                {
                    Id               = v.Id,
                    VideoUrl         = v.VideoUrl,
                    PhotoUrl         = v.PhotoUrl,
                    Name             = v.Name,
                    Description      = v.Description,
                    Visibility       = v.Visibility.ToString(),
                    Blocked          = v.Blocked,
                    AllowComments    = v.AllowComments,
                    AllowRaiting     = v.AllowRaiting,
                    NumberOfLikes    = v.NumberOfLikes,
                    NumberOfDislikes = v.NumberOfDislikes,
                    NumberOfViews    = v.NumberOfViews,
                    CreationDate     = v.CreationDate.ToString("dd.mm.yyyy")
                };
                videos.Add(newVDTO);
            }
            return(videos);
        }
Exemple #2
0
        public static SingleUserDTO ConvertUserToDTO(User user)
        {
            RoleType      role    = (RoleType)user.Role;
            SingleUserDTO newVDTO = new SingleUserDTO
            {
                Id = user.Id,
                profilePictureUrl = user.ProfilePictureUrl,
                Username          = user.Username,
                Password          = user.Password,
                FirstName         = user.FirstName,
                LastName          = user.LastName,
                Email             = user.Email,
                Description       = user.Description,
                RegistrationDate  = user.RegistrationDate.ToString("dd.mm.yyyy"),
                Role          = role.ToString(),
                Blocked       = user.Blocked,
                UsersVideos   = VideoForUser.ConvertVideoToDTO(user.UserVideos),
                LikedVideos   = SingleVideoDTO.ConvertLikedVideosToDTO(user.LikedVideos),
                UserComments  = CommentForUserDTO.ConvertCommentToDTO(user.UserComments),
                LikedComments = CommentForUserDTO.ConvertCommentToDTO(user.LikedComments),
                Followers     = UserForVideoComment.ConvertFollowers(user.Followers),
                Following     = UserForVideoComment.ConvertFollowers(user.Following)
            };

            return(newVDTO);
        }
Exemple #3
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);
        }
Exemple #4
0
        public static VideoForUser ConvertVideo(Video v)
        {
            VideoForUser newVDTO = new VideoForUser
            {
                Id               = v.Id,
                VideoUrl         = v.VideoUrl,
                PhotoUrl         = v.PhotoUrl,
                Name             = v.Name,
                Description      = v.Description,
                Visibility       = v.Visibility.ToString(),
                Blocked          = v.Blocked,
                AllowComments    = v.AllowComments,
                AllowRaiting     = v.AllowRaiting,
                NumberOfLikes    = v.NumberOfLikes,
                NumberOfDislikes = v.NumberOfDislikes,
                NumberOfViews    = v.NumberOfViews,
                CreationDate     = v.CreationDate.ToString("dd.mm.yyyy")
            };

            return(newVDTO);
        }
Exemple #5
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);
        }