示例#1
0
        // GET: Blog/author/{id}/{author}
        public ActionResult IndexAuthor(Guid id, string author)
        {
            string section = "blog";
            string qString = "/blog";

            Language    language    = new Language("en-US");
            ContentPage contentPage = new ContentPage(qString);

            if (contentPage.PageID != Guid.Empty)
            {
                ViewData     = contentPage.GetSections();
                ViewBag.Meta = contentPage.MetaTags;

                MenuItem sideMenu = new MenuItem(Request.Url.AbsolutePath);
                ViewBag.SideMenu = sideMenu.SiblingMenuCode();

                ViewBag.Highlight = "$('." + section + "').addClass('active');";
            }

            ViewBag.BlogHeaderExt = "Blogs by: " + BlogPost.GetAuthorName(id);

            //Paging defaults
            int pg = 1;
            int sz = 20;

            //Retrieve / Store paging parameters
            if (Request.QueryString["pg"] != null)
            {
                if (!Int32.TryParse(Request.QueryString["pg"].ToString(), out pg))
                {
                    pg = 1;
                }
            }
            if (Request.QueryString["sz"] != null)
            {
                if (!Int32.TryParse(Request.QueryString["sz"].ToString(), out sz))
                {
                    sz = 20;
                }
            }

            BlogPosts       posts = new BlogPosts();
            List <BlogPost> blogs = posts.PostsByAuthor(id, pg, sz);

            ViewBag.Pager = posts.ByAuthorPager(id, author, pg, sz);

            return(View("Index", blogs));
        }