예제 #1
0
        public static List <SingleVideoDTO> ConvertLikedVideosToDTO(IEnumerable <Video> video)
        {
            List <SingleVideoDTO> singleVideoDTO = new List <SingleVideoDTO>();

            foreach (var v in video)
            {
                SingleVideoDTO newDTO = new SingleVideoDTO
                {
                    Id               = v.Id,
                    VideoUrl         = v.VideoUrl,
                    PhotoUrl         = v.PhotoUrl,
                    Name             = v.Name,
                    Description      = v.Description,
                    Visibility       = v.Visibility.ToString(),
                    Blocked          = v.Blocked,
                    Deleted          = v.Deleted,
                    AllowComments    = v.AllowComments,
                    AllowRaiting     = v.AllowRaiting,
                    NumberOfLikes    = v.NumberOfLikes,
                    NumberOfDislikes = v.NumberOfDislikes,
                    NumberOfViews    = v.NumberOfViews,
                    CreationDate     = v.CreationDate.ToString("dd.mm.yyyy"),
                    Owner            = UserForVideoComment.ConvertUserForVideoComment(v.Owner),
                    Comments         = CommentForVideoDTO.ConvertCommentToDTO(v.Comments)
                };
                singleVideoDTO.Add(newDTO);
            }
            return(singleVideoDTO);
        }
예제 #2
0
        public static List <VideoDTO> ConvertVideosToDTO(IEnumerable <Video> videos)
        {
            List <VideoDTO> videosDto = new List <VideoDTO>();

            foreach (var video in videos)
            {
                VideoDTO newVDTO = new VideoDTO
                {
                    Id               = video.Id,
                    VideoUrl         = video.VideoUrl,
                    PhotoUrl         = video.PhotoUrl,
                    Name             = video.Name,
                    Description      = video.Description,
                    Visibility       = video.Visibility,
                    Blocked          = video.Blocked,
                    AllowComments    = video.AllowComments,
                    AllowRaiting     = video.AllowRaiting,
                    NumberOfLikes    = video.NumberOfLikes,
                    NumberOfDislikes = video.NumberOfDislikes,
                    NumberOfViews    = video.NumberOfViews,
                    CreationDate     = video.CreationDate.ToString("dd.mm.yyyy"),
                    User             = UserForVideoComment.ConvertUserForVideoComment(video.Owner)
                };
                videosDto.Add(newVDTO);
            }
            return(videosDto);
        }
예제 #3
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);
        }
예제 #4
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);
        }
예제 #5
0
        public static UserForVideoComment ConvertUserForVideoComment(User user)
        {
            UserForVideoComment userForVideo = new UserForVideoComment();

            userForVideo.Id                = user.Id;
            userForVideo.Username          = user.Username;
            userForVideo.FirstName         = user.FirstName;
            userForVideo.LastName          = user.LastName;
            userForVideo.Email             = user.Email;
            userForVideo.Description       = user.Description;
            userForVideo.RegistrationDate  = user.RegistrationDate.ToString("dd.mm.yyyy");
            userForVideo.Blocked           = user.Blocked;
            userForVideo.profilePictureUrl = user.ProfilePictureUrl;
            return(userForVideo);
        }
예제 #6
0
        public static List <CommentForVideoDTO> ConvertCommentToDTO(IEnumerable <Comment> comments)
        {
            List <CommentForVideoDTO> commentsDTO = new List <CommentForVideoDTO>();

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

            return(commentsDTO);
        }
예제 #7
0
        public static List <UserForVideoComment> ConvertFollowers(IEnumerable <User> followers)
        {
            List <UserForVideoComment> userDTO = new List <UserForVideoComment>();

            foreach (var user in followers)
            {
                UserForVideoComment userForVideo = new UserForVideoComment();
                userForVideo.Id                = user.Id;
                userForVideo.Username          = user.Username;
                userForVideo.FirstName         = user.FirstName;
                userForVideo.LastName          = user.LastName;
                userForVideo.Email             = user.Email;
                userForVideo.Description       = user.Description;
                userForVideo.RegistrationDate  = user.RegistrationDate.ToString("dd.mm.yyyy");
                userForVideo.Blocked           = user.Blocked;
                userForVideo.profilePictureUrl = user.ProfilePictureUrl;

                userDTO.Add(userForVideo);
            }
            return(userDTO);
        }
예제 #8
0
        public static VideoDTO ConvertVideoToDTO(Video video)
        {
            VideoDTO newVDTO = new VideoDTO
            {
                Id               = video.Id,
                VideoUrl         = video.VideoUrl,
                PhotoUrl         = video.PhotoUrl,
                Name             = video.Name,
                Description      = video.Description,
                Visibility       = video.Visibility,
                Blocked          = video.Blocked,
                AllowComments    = video.AllowComments,
                AllowRaiting     = video.AllowRaiting,
                NumberOfLikes    = video.NumberOfLikes,
                NumberOfDislikes = video.NumberOfDislikes,
                NumberOfViews    = video.NumberOfViews,
                CreationDate     = video.CreationDate.ToString("dd.mm.yyyy"),
                User             = UserForVideoComment.ConvertUserForVideoComment(video.Owner)
            };

            return(newVDTO);
        }
예제 #9
0
        public static LikeCommentDTO ConvertCommentToDTO(LikeDislikeComment likeDislikeComment)
        {
            string likeDislike = "";

            if (likeDislikeComment.LikeOrDislike == true)
            {
                likeDislike = "Like";
            }
            else
            {
                likeDislike = "false";
            }
            LikeCommentDTO newDto = new LikeCommentDTO
            {
                Id            = likeDislikeComment.Id,
                LikeOrDislike = likeDislike,
                CreationDate  = likeDislikeComment.CreationDate.ToString("dd.mm.yyyy"),
                Owner         = UserForVideoComment.ConvertUserForVideoComment(likeDislikeComment.Owner),
                Comment       = CommentForUserDTO.SingleConvertCommentToDTO(likeDislikeComment.Comment)
            };

            return(newDto);
        }