Ejemplo n.º 1
0
        public ActionResult Dynasty(int?dynasty, int?page)
        {
            if (dynasty != null)
            {
                int pageSize  = 10;
                int pageIndex = 1;
                IPagedList <lstPostViewModel> post = null;
                Dynasty d = (Dynasty)dynasty;
                ViewBag.catname = d.GetDisplayName();
                pageIndex       = page.HasValue ? Convert.ToInt32(page) : 1;
                post            = db.postRepository.AllPosts()
                                  .Where(m => m.status)
                                  .Where(m => m.dynasty.Equals(d.ToString()))
                                  .OrderByDescending(m => m.create_date)
                                  .Select(c => new lstPostViewModel
                {
                    post_id     = c.post_id,
                    post_title  = c.post_title,
                    post_teaser = c.post_teaser,
                    ViewCount   = c.ViewCount,
                    AvatarImage = c.AvatarImage,
                    create_date = c.create_date,
                    tagsname    = c.Tbl_Tags.FirstOrDefault().TagName,
                    slug        = c.post_slug
                }).ToPagedList(pageIndex, pageSize);

                return(View(post));
            }
            return(View("DynastyAll"));
        }