示例#1
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;
        }
        public TagData GetTagFromId(int tagId)
        {
            Tag tag = NHibernateHelper.GetCurrentSession().Get<Tag>(tagId);

            TagData tagData = null;

            if (tag != null)
            {
                tagData = new TagData(tag.Id, tag.TagName);
            }

            return tagData;
        }