示例#1
0
        public virtual ActionResult List(int page = 1)
        {
            var viewModel = new ListPostViewModel(_blogRepository, page);

            ViewBag.Title = "Latest Posts";
            viewModel.Posts = viewModel.Posts.Take(ItemsPerPage);
            return View("List", viewModel);
        }
示例#2
0
        //Get Blog/Category Action
        public virtual ViewResult Category(string selectedCategory, int categoryPage = 1)
        {
            var viewModel = new ListPostViewModel(_blogRepository, selectedCategory, "Category", categoryPage);

            if (viewModel.Category == null){
                throw new HttpException(404, "Category not found.");
            }
            ViewBag.Title = "The Power Coder | Category: " + selectedCategory;
            ViewBag.Caption = String.Format(@"Articles about " + "{0}", viewModel.Category.Name);

            if (viewModel.Category == null){
                throw new HttpException(404, "Category not found.");
            }
            ViewBag.Title = String.Format(@"Latest posts on category ""{0}""", viewModel.Category.Name);

            viewModel.Posts = viewModel.Posts.Take(ItemsPerPage);
            return View("List", viewModel);
        }
示例#3
0
        //Get Blog/Search Action
        public virtual ViewResult Search(string txtSearch, int page = 1)
        {
            ViewBag.Title = String.Format(@"Lists of posts found
                        for search text ""{0}""", txtSearch);

            var viewModel = new ListPostViewModel(_blogRepository, txtSearch, "Search",
                                                  page);

            viewModel.Posts = viewModel.Posts.Take(ItemsPerPage);
            return View("List", viewModel);
        }
示例#4
0
        //Get Blog/Tag Action
        public virtual ViewResult Tag(string tag, int tagPage = 1)
        {
            var viewModel = new ListPostViewModel(_blogRepository, tag, "Tag", tagPage);

            if (viewModel.Tag == null){
                throw new HttpException(404, "Tag not found.");
            }
            ViewBag.Title = "The Power Coder | Tag: " + tag;
            ViewBag.Caption = String.Format(@"Articles that mention " + "{0}", viewModel.Tag.Name);

            if (viewModel.Tag == null){
                throw new HttpException(404, "Tag not found.");
            }
            ViewBag.Title = String.Format(@"Latest posts tagged on ""{0}""", viewModel.Tag.Name);

            viewModel.Posts = viewModel.Posts.Take(ItemsPerPage);
            return View("List", viewModel);
        }