Exemple #1
0
        public static CommentViewModel Convert(Comment comment)
        {
            CommentViewModel commentViewModel = new CommentViewModel();

            commentViewModel.CommentID = comment.CommentID;
            commentViewModel.Content   = comment.Content;
            commentViewModel.PostID    = comment.PostID;
            commentViewModel.UserID    = int.Parse(comment.UserID);
            commentViewModel.User      = UserConverter.Convert(comment.User);
            return(commentViewModel);
        }
Exemple #2
0
        public static PostViewModel Convert(Post post)
        {
            PostViewModel postViewModel = new PostViewModel();

            postViewModel.Description     = post.Description;
            postViewModel.PostDate        = post.PostDate;
            postViewModel.PostID          = post.PostID;
            postViewModel.UserID          = post.UserID;
            postViewModel.Title           = post.Title;
            postViewModel.Rating          = post.Rating;
            postViewModel.MovieID         = post.MovieID;
            postViewModel.MoviePictureURL = post.MoviePictureURL;
            postViewModel.MoviePictureID  = post.MoviePictureID;
            postViewModel.Comments        = CommentConverter.ConvertList(post.Comments);
            postViewModel.User            = UserConverter.Convert(post.User);
            postViewModel.Movie           = MovieConverter.Convert(post.Movie);

            return(postViewModel);
        }
Exemple #3
0
 public static List <PostViewModel> ConvertList(IEnumerable <Post> posts)
 {
     return(posts.Select(p =>
     {
         PostViewModel postViewModel = new PostViewModel();
         postViewModel.Description = p.Description;
         postViewModel.MovieID = p.MovieID;
         postViewModel.PostDate = p.PostDate;
         postViewModel.PostID = p.PostID;
         postViewModel.UserID = p.UserID;
         postViewModel.Title = p.Title;
         postViewModel.Rating = p.Rating;
         postViewModel.MoviePictureID = p.MoviePictureID;
         postViewModel.MoviePictureURL = p.MoviePictureURL;
         postViewModel.Comments = CommentConverter.ConvertList(p.Comments);
         postViewModel.User = UserConverter.Convert(p.User);
         postViewModel.Movie = MovieConverter.Convert(p.Movie);
         return postViewModel;
     }).ToList());
 }