示例#1
0
        private TagHomeVModel GetPostsForTag(int tagId, string bid,
                                             int pageNum, string order)
        {
            if (bid == null)
            {
                bid = blogId;
            }
            SeqTag tag = tagRep.GetTag(tagId, bid);
            //if (tag == null) return null;
            IQueryable <SeqPost> tagPosts = tagRep.PostsForTag(
                tag, order, pageSize, pageNum);

            TagHomeVModel thvm = new TagHomeVModel(tagId);

            thvm.Tag          = tag.Name;
            thvm.BlogId       = bid;
            thvm.RecentPosts  = VModelFactory.BlogPosts(tagPosts);
            thvm.Controller   = "Tag";
            thvm.CurrentPage  = pageNum;
            thvm.PageSize     = pageSize;
            thvm.HasMorePages = thvm.RecentPosts.Count() > 0;
            //thvm.News = VModelFactory.BlogPosts(catRep.RecentNews(5));
            //thvm.Books = VModelFactory.Books(bookRep.AllBooks());
            return(thvm);
        }
示例#2
0
	public ActionResult GetSinglePost(string bid, int id)
	{
		if (bid == null)
			bid = blogId;
		IQueryable<SeqPost> sp = postsRep.GetPost(id);
		BlogHomeVModel bhvm = new BlogHomeVModel();
		bhvm.BlogId = bid;
		bhvm.RecentPosts = VModelFactory.BlogPosts(sp);
		bhvm.AllCategories = VModelFactory.AllCategories(
										catRep.AllCategories(bid),bid);
		return View(bhvm);
	}
示例#3
0
        public ActionResult PostsForTag(int tagId, string bid, int pageNum,
                                        string order)
        {
            TagHomeVModel thvm = GetPostsForTag(tagId, bid, pageNum, order);

            if (thvm == null)
            {
                return(View("NoTagsFound"));
            }
            thvm.Action        = "PostsForTag";
            thvm.AllCategories = VModelFactory.AllCategories(
                catRep.AllCategories(bid), bid);
            return(View("PostsForTag", thvm));
        }
示例#4
0
	/// <summary>
	/// Fetch a page of blog posts and returns a partial view. 
	/// </summary>
	/// <param name="bid">Blog id</param>
	/// <param name="pageNum">The requested page of blog posts.</param>
	/// <returns>A partial view containing a page of blog posts.</returns>
	public ActionResult AjaxPostPage(string bid = null, int pageNum = 1)
	{
		if (pageNum < 1) pageNum = 1;
		if (bid == null) bid = blogId;
		BlogHomeVModel bhvm = new BlogHomeVModel();
		bhvm.BlogId = bid;
		IQueryable<SeqPost> results = postsRep.GetPostPage(pageSize, pageNum, bid);
		bhvm.RecentPosts = VModelFactory.BlogPosts(results);
		bhvm.CurrentPage = pageNum;
		bhvm.PageSize = pageSize;
		bhvm.HasMorePages = bhvm.RecentPosts.Count() > 0;
		bhvm.Controller = "post";
		bhvm.Action = "AjaxPostPage";
		return PartialView(bhvm);
	}
示例#5
0
	private PostsForCategoryVModel GetPostsForCategory(string bid, string category,
		string order, int pageNum=1)
	{
		if (bid == null) bid = blogId;
		IQueryable<SeqPost> catPosts = postsRep.PostsForCategory(
												 bid, category, order, pageSize, pageNum);

		PostsForCategoryVModel pcvm = new PostsForCategoryVModel(category);
		pcvm.BlogId = bid;
		pcvm.Controller = "Category";
		pcvm.AllPosts = VModelFactory.BlogPosts(catPosts);
		pcvm.CurrentPage = pageNum;
		pcvm.PageSize = pageSize;
		pcvm.HasMorePages = pcvm.AllPosts.Count() > 0;
		pcvm.AllCategories = VModelFactory.AllCategories(
									catRep.AllCategories(bid),bid);
		//pcvm.News = VModelFactory.BlogPosts(catRep.RecentNews(5));
		//pcvm.Books = VModelFactory.Books(bookRep.AllBooks());
		return pcvm;
	}