public ViewBlogPostModelContainer ReadPostForViewByVisitor(string publicationName, int postId)
        {
            var content = BlogBiz.ReadPostForViewByVisitor(publicationName, postId);

            VisitBiz.IncrementContentVisits(content.Id);
            UnitOfWork.SaveChanges();
            return(new ViewBlogPostModelContainer()
            {
                BlogInfo = BlogBiz.Read(b => b.Id == content.PublicationId).MapTo <BlogInfoPM>().Single(),
                Post = content.GetContentInfoWithTextPM(),
                Tags = content.Tags.Select(tag => tag.GetPresentationModel()).ToList(),
                ArchiveItems = PublicationBiz.ReadPublicationArchivedItemsCalendar(content.PublicationId.Value, ContentType.BlogPost)
                               .Select(item => new ContentArchiveItemPM(item.Item1, item.Item2)),
                Links = BlogBiz.ReadBlogLinks(content.PublicationId.Value)
                        .MapTo <BlogLinkPM>()
                        .ToList(),
                Comments = content.Comments
                           .Where(comment => !comment.IsPrivate)
                           .Select(comment => comment.GetCommentInfoPM()).ToList(),
                LatestPosts = BlogBiz.ReadUserPublishedPostsForViewByVisitor(content.Publication.CreatorId)
                              .Take(10)
                              .MapTo <ContentInfoWithTextPM>()
                              .ToList()
            });
        }
 public IEnumerable <BlogInfoForGenerateLinkPM> ReadBlogs(int pageIndex, int pageSize)
 {
     return(BlogBiz.Read()
            .OrderBy(blog => blog.Title)
            .Skip((pageIndex - 1) * pageSize)
            .Take(pageSize)
            .MapTo <BlogInfoForGenerateLinkPM>()
            .ToList());
 }
        public ViewBlogPostModelContainer ReadPostForPreview(string publicationName, int postId)
        {
            var content = BlogBiz.ReadPostForPreview(publicationName, postId);

            VisitBiz.IncrementContentVisits(content.Id);
            UnitOfWork.SaveChanges();
            return(new ViewBlogPostModelContainer()
            {
                BlogInfo = BlogBiz.Read(b => b.Id == content.PublicationId).MapTo <BlogInfoPM>().Single(),
                Post = content.GetContentInfoWithTextPM(),
                Tags = content.Tags.Select(tag => tag.GetPresentationModel()).ToList(),
            });
        }
        public ViewBlogArchiveModelContainer ReadArchiveForViewByVisitor(string publicationName, int?year, int?month)
        {
            var blog = BlogBiz.Read(b => b.Name == publicationName)
                       .Include(b => b.Links)
                       .Single();
            var postTitles = year.HasValue && month.HasValue ?
                             BlogBiz.ReadBlogPublishedPosts(blog.Id, year.Value, month.Value) :
                             BlogBiz.ReadBlogPublishedPosts(blog.Id);

            return(new ViewBlogArchiveModelContainer()
            {
                Year = year,
                Month = month,
                BlogInfo = blog.GetBlogInfo(),
                Links = blog.Links.Select(link => link.GetLinkPM()).ToList(),
                PostTitles = postTitles.MapTo <ContentInfo2PM>().ToList(),
                ArchiveItems = PublicationBiz.ReadPublicationArchivedItemsCalendar(blog.Id, ContentType.BlogPost)
                               .Select(item => new ContentArchiveItemPM(item.Item1, item.Item2)),
            });
        }