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); }
public static CommentForUserDTO SingleConvertCommentToDTO(Comment comment) { CommentForUserDTO newDto = new CommentForUserDTO { Id = comment.Id, Description = comment.Description, NumberOfLikes = comment.NumberOfLikes, NumberOfDislikes = comment.NumberOfDislikes, CreationDate = comment.CreationDate.ToString("dd.mm.yyyy"), }; return(newDto); }
public static List <CommentForUserDTO> ConvertCommentToDTO(IEnumerable <Comment> comments) { List <CommentForUserDTO> commentsDTO = new List <CommentForUserDTO>(); foreach (var comment in comments) { CommentForUserDTO newDto = new CommentForUserDTO { Id = comment.Id, Description = comment.Description, NumberOfLikes = comment.NumberOfLikes, NumberOfDislikes = comment.NumberOfDislikes, CreationDate = comment.CreationDate.ToString("dd.mm.yyyy"), }; commentsDTO.Add(newDto); } return(commentsDTO); }
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); }