public static PostModel ToPostModel(this BlogPostPageViewModel blogPostPageViewModel, PostEntity postEntity) { var postModel = new PostModel { Post = postEntity, DisqusEnabled = blogPostPageViewModel.DisqusEnabled }; return(postModel); }
/// <summary> /// The map from. /// </summary> /// <param name="blog"> /// The blog to map from. /// </param> /// <param name="blogPost"> /// The blog Post. /// </param> /// <returns> /// The blog post page view model. /// </returns> public BlogPostPageViewModel MapFrom(Blog blog, BlogPost blogPost, Tag tags) { var blogPostPageViewModel = new BlogPostPageViewModel { ShowEditLink = blog.Author.Equals(this.identityService.GetCurrentUser()), BlogUrl = blog.Url, Body = blogPost.Body, Author = blog.Author.Username, PostDate = blogPost.PostDate.ToString("dd MMMM yyyy"), Form = this.blogPostFormViewModelMapper.MapFrom(blogPost), Comments = blogPost.Comments.MapAllUsing(this.blogPostCommentPageViewModelMapper).ToList(), ArchiveSectionViewModel = this.archiveSectionViewModelMapper.MapFrom(blog), Title = blogPost.Title, Url = blogPost.Url, }; blogPost.Tags.ForEach(x => blogPostPageViewModel.AssignedTags.Add("{0}-{1}".FormatWith(x.Name, x.Id))); blogPostPageViewModel.Tags = tags; return blogPostPageViewModel; }