예제 #1
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);
        }
예제 #2
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());
 }