コード例 #1
0
        public ActionResult Archive(int year, int month, int? page = 1) {
            int pageIndex = page.GetValueOrDefault(1) - 1; // Given pageIndex is user-friendly, not 0-based
            
            var selection = this.BlogService.GetArchiveSelection(new DateTime(year, month, 1), pageIndex);

            var model = new BlogListViewModel { Selection = selection, PageIndex = page.GetValueOrDefault(1), };

            ViewBag.Title = string.Format("Inlägg från {0}-{1}", year, month);
            return View("List", model);
        }
コード例 #2
0
        public ActionResult Search(string q, int? page = 1) {
            int pageIndex = page.GetValueOrDefault(1) - 1; // Given pageIndex is user-friendly, not 0-based

            var selection = this.BlogService.SearchPosts(q, pageIndex);

            var model = new BlogListViewModel { Selection = selection, PageIndex = page.GetValueOrDefault(1), };

            ViewBag.Title = string.Format("Sökresultat för '{0}'", q);
            return View("List", model);
        }
コード例 #3
0
        public ActionResult Index(int? page = 1) {
            int pageIndex = page.GetValueOrDefault(1) - 1; // Given pageIndex is user-friendly, not 0-based

            var selection = this.BlogService.GetSelection(pageIndex);

            var model = new BlogListViewModel { Selection = selection, PageIndex = page.GetValueOrDefault(1), };

            ViewBag.Title = "Senaste inläggen";
            return View("List", model);
        }
コード例 #4
0
        public ActionResult Tag(string t, int? page = 1) {
            t = HttpUtility.UrlDecode(t);
            int pageIndex = page.GetValueOrDefault(1) - 1; // Given pageIndex is user-friendly, not 0-based

            var selection = this.BlogService.GetTagsSelection(t, pageIndex);

            var model = new BlogListViewModel { Selection = selection, PageIndex = page.GetValueOrDefault(1), };

            ViewBag.Title = string.Format("Inlägg taggade som '{0}'", t);
            return View("List", model);
        }
コード例 #5
0
        public ActionResult Index(int? page = 1)
        {
            int pageIndex = page.GetValueOrDefault(1) - 1; // Given pageIndex is user-friendly, not 0-based

            var posts = this.BlogQuery.ListPosts();

            var model = new BlogListViewModel(posts, PageSize, pageIndex, this.ControllerContext);

            this.ViewBag.Title = "Senaste inläggen";

            return this.View("List", model);
        }
コード例 #6
0
        public ActionResult Search(string q, int? page = 1)
        {
            int pageIndex = page.GetValueOrDefault(1) - 1; // Given pageIndex is user-friendly, not 0-based

            string searchTerm = HttpUtility.UrlDecode(q ?? string.Empty);

            var posts = this.BlogQuery.Search(searchTerm);

            var model = new BlogListViewModel(posts, PageSize, pageIndex, this.ControllerContext);

            this.ViewBag.Title = $"Sökresultat för '{q}'";

            return this.View("List", model);
        }
コード例 #7
0
        public ActionResult Archive(int year, int month, int? page = 1)
        {
            int pageIndex = page.GetValueOrDefault(1) - 1; // Given pageIndex is user-friendly, not 0-based

            var archiveDate = new DateTime(year, month, 1);

            var posts = this.BlogQuery.ListPostsByArchive(archiveDate);

            var model = new BlogListViewModel(posts, PageSize, pageIndex, this.ControllerContext);

            this.ViewBag.Title = $"Inlägg från {year}-{month}";

            return this.View("List", model);
        }
コード例 #8
0
        public ActionResult Tag(string t, int? page = 1)
        {
            if (string.IsNullOrWhiteSpace(t))
            {
                return this.Index();
            }

            int pageIndex = page.GetValueOrDefault(1) - 1; // Given pageIndex is user-friendly, not 0-based

            string tagName = HttpUtility.UrlDecode(t);

            var posts = this.BlogQuery.ListPostsByTag(tagName);

            var model = new BlogListViewModel(posts, PageSize, pageIndex, this.ControllerContext);

            this.ViewBag.Title = $"Inlägg taggade som '{t}'";
            return this.View("List", model);
        }