示例#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);
        }