Пример #1
0
        public BlogListingView ListBlogsForFrontPage(int pageNumber, int recordsPerPage)
        {
            int totalRecords = 0;
            IList<BlogItemListingData> blogItems = BlogRepository.ListBlogs(pageNumber, recordsPerPage, out totalRecords);

            BlogListingView blogListing = new BlogListingView(pageNumber, recordsPerPage, totalRecords);

            foreach (BlogItemListingData blog in blogItems)
            {
                BlogListingView.BlogItemView blogItem = new BlogListingView.BlogItemView(blog.Id, blog.Title,
                    blog.PostedDate, blog.NumComments, blog.NumImages, blog.BlogType, blog.AbstractText);

                foreach (TagData tagData in blog.Tags)
                {
                    blogItem.Tags.Add(new BlogListingView.TagView(tagData.Id, tagData.TagName));
                }

                if (blog.PreviewImage != null)
                {
                    Image image = blog.PreviewImage;
                    blogItem.PreviewImage = new BlogListingView.PreviewImageView(image.Id, image.FileName, image.Caption, image.AltText);
                }

                blogListing.Blogs.Add(blogItem);
            }

            return blogListing;
        }
Пример #2
0
        public BlogListingView GetTaggedBlogsForFrontPage(int tagId, int pageNumber, int recordsPerPage, out TagData tag)
        {
            tag = BlogRepository.GetTagFromId(tagId);

            int totalRecords = 0;
            IList<BlogItemListingData> blogItems = BlogRepository.GetTaggedBlogs(tagId, pageNumber, recordsPerPage, out totalRecords);

            BlogListingView blogListing = new BlogListingView(pageNumber, recordsPerPage, totalRecords);

            foreach (BlogItemListingData blog in blogItems)
            {
                BlogListingView.BlogItemView blogItem = new BlogListingView.BlogItemView(blog.Id, blog.Title,
                    blog.PostedDate, blog.NumComments, blog.NumImages, blog.BlogType, blog.AbstractText);

                foreach (TagData tagData in blog.Tags)
                {
                    blogItem.Tags.Add(new BlogListingView.TagView(tagData.Id, tagData.TagName));
                }

                blogListing.Blogs.Add(blogItem);
            }

            return blogListing;
        }