Beispiel #1
0
        public ViewResult Posts(int p = 1)
        {
            var viewModel = new ListViewModel(_blogRepository, p);

            ViewBag.title = "Latest Posts";
            return View("List", viewModel);
        }
        public ViewResult Category(string category, int p = 1)
        {
            var viewModel = new ListViewModel(_blogRepository, category, "Category", p);

              if (viewModel.Category == null)
            throw new HttpException(404, "Category not found");

              ViewBag.Title = String.Format(@"Latest posts on category ""{0}""", viewModel.Category.Name);
              return View("List", viewModel);
        }
Beispiel #3
0
    /// <summary>
    /// Return the posts belongs to a tag.
    /// </summary>
    /// <param name="tag">Url slug</param>
    /// <param name="p">Pagination number</param>
    /// <returns></returns>
    public ViewResult Tag(string tag, int p = 1)
    {
      var viewModel = new ListViewModel(_blogRepository, tag, "Tag", p);

      if (viewModel.Tag == null)
        throw new HttpException(404, "Tag not found");

      ViewBag.Title = String.Format(@"Latest posts tagged on ""{0}""", viewModel.Tag.Name);
      return View("List", viewModel);
    }
        public ViewResult Search(string s, int p = 1)
        {
            ViewBag.Title = String.Format(@"Lists of posts found for search text ""{0}""", s);

              var viewModel = new ListViewModel(_blogRepository, s, "Search", p);
              return View("List", viewModel);
        }