Beispiel #1
0
        void ApplyUrlQueryTagsToBlogSearchRequest(BlogArticleSearchRequest request)
        {
            var tagQueryString = Request.QueryString["tags"];

            if (string.IsNullOrEmpty(tagQueryString))
            {
                return;
            }

            var urlQueryTags = tagQueryString.Split(',');

            if (urlQueryTags != null && urlQueryTags.Any())
            {
                var tagSearchRequest = new TagSearchRequest
                {
                    RootPath = Context.Site.RootPath,
                    TagNames = urlQueryTags
                };

                var tags = tagSearchService.Search(tagSearchRequest);

                if (tags.Results.Any())
                {
                    request.TagIds = tags.Results.Select(u => new ID(u.Id)).ToArray();
                }
            }
        }
Beispiel #2
0
        public ActionResult LatestNews()
        {
            var request = new BlogArticleSearchRequest()
            {
                RootPath = Context.Site.RootPath,
                Page     = 1,
                PageSize = 3, // hard code to 10 for now
                SortType = BlogArticleSearchRequestSortType.BlogDateDescending
            };

            var searchResult = blogArticleService.Search(request);

            return(View("~/Views/Feature/Blog/LatestNews.cshtml", searchResult));
        }
Beispiel #3
0
        public ActionResult LastUpdatedDate()
        {
            var request = new BlogArticleSearchRequest()
            {
                RootPath = Context.Site.RootPath,
                Page     = 1,
                PageSize = 1, // hard code to 10 for now
                SortType = BlogArticleSearchRequestSortType.BlogDateDescending
            };

            var searchResult = blogArticleService.Search(request);
            var lastUpdated  = searchResult.Results.FirstOrDefault()?.BlogDate;

            return(View("~/Views/Feature/Blog/_LastUpdated.cshtml", lastUpdated));
        }
Beispiel #4
0
        public ActionResult BlogListing(int?page)
        {
            var request = new BlogArticleSearchRequest()
            {
                RootPath = Context.Site.RootPath,
                Page     = page ?? 1,
                PageSize = 10, // hard code to 10 for now
                SortType = BlogArticleSearchRequestSortType.BlogDateDescending
            };

            ApplyUrlQueryTagsToBlogSearchRequest(request);

            var searchResult = blogArticleService.Search(request);

            return(View("~/Views/Feature/Blog/BlogListing.cshtml", searchResult));
        }