示例#1
0
	public ActionResult PostPage(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.AllCategories = VModelFactory.AllCategories(catRep.AllCategories(bid),bid);
		bhvm.CurrentPage = pageNum;
		bhvm.PageSize = pageSize;
		bhvm.HasMorePages = bhvm.RecentPosts.Count() > 0;
		bhvm.Controller = "post";
		bhvm.Action = "PostPage";
		return View("Index", bhvm);
	}
示例#2
0
        Post[] IMetaWeblog.GetRecentPosts(string blogid, string username,
                                          string password, int numberOfPosts)
        {
            if (InvalidUser(username, password))
            {
                throw new XmlRpcFaultException(INVALID_CREDENTIALS,
                                               INVALID_CREDENTIALS_MSG);
            }
            List <Post>          posts       = new List <Post>();
            IQueryable <SeqPost> recentPosts =
                postsRep.GetPostPage(numberOfPosts, 1, blogid);

            foreach (SeqPost sp in recentPosts)
            {
                Post p = new Post();
                p.postid      = sp.PostId;
                p.title       = sp.Title;
                p.dateCreated = sp.CreateDate;
                p.description = sp.Description;
                string[] category = new string[1];
                category[0] = (sp.SeqCategory == null)
                           ? "" : sp.SeqCategory.Name;
                p.categories = category;
                posts.Add(p);
            }
            return(posts.ToArray());
        }