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); }
/// <summary> /// Create a new <code>WebComicVModel</code> that clones the properties of /// its superclass. /// </summary> /// <param name="bhvm">The parent <code>BlogHomeVModel</code>to clone. /// </param> public WebComicVModel(BlogHomeVModel bhvm) { this.RecentPosts = bhvm.RecentPosts; this.AllCategories = bhvm.AllCategories; this.Action = bhvm.Action; this.Controller = bhvm.Controller; this.CurrentPage = bhvm.CurrentPage; this.HasMorePages = bhvm.HasMorePages; this.PageSize = bhvm.PageSize; this.BlogId = bhvm.BlogId; bhvm = null; }
/// <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); }