示例#1
0
        public async Task <IActionResult> Index(int page = 1)
        {
            var pagesize = _blogConfig.ContentSettings.PostListPageSize;
            var posts    = await _postService.GetPagedPostsAsync(pagesize, page);

            var count = _cache.GetOrCreate(CacheDivision.General, "postcount", _ => _postService.CountVisiblePosts());

            var list = new StaticPagedList <PostListEntry>(posts, page, pagesize, count);

            return(View(list));
        }
示例#2
0
        public async Task <IActionResult> Index(int page = 1, [FromServices] IMemoryCache memoryCache = null)
        {
            try
            {
                var pagesize = _blogConfig.ContentSettings.PostListPageSize;
                var postList = await _postService.GetPagedPostsAsync(pagesize, page);

                var postCount = memoryCache.GetOrCreate(StaticCacheKeys.PostCount, entry => _postService.CountVisiblePosts().Item);

                var postsAsIPagedList = new StaticPagedList <PostListItem>(postList, page, pagesize, postCount);
                return(View(postsAsIPagedList));
            }
            catch (Exception e)
            {
                Logger.LogError(e, "Error getting post list.");
                return(ServerError("Error getting post list."));
            }
        }
示例#3
0
        public async Task <IActionResult> Index(int page = 1)
        {
            try
            {
                var pagesize = _blogConfig.ContentSettings.PostListPageSize;
                var postList = await _postService.GetPagedPostsAsync(pagesize, page);

                var postCount = _cache.GetOrCreate(CacheDivision.General, "postcount", entry => _postService.CountVisiblePosts());

                var postsAsIPagedList = new StaticPagedList <PostListEntry>(postList, page, pagesize, postCount);
                return(View(postsAsIPagedList));
            }
            catch (Exception e)
            {
                Logger.LogError(e, "Error getting post list.");
                return(ServerError("Error getting post list."));
            }
        }
示例#4
0
        public async Task <IActionResult> Index(int page = 1, [FromServices] IMemoryCache memoryCache = null)
        {
            int pagesize = _blogConfig.ContentSettings.PostListPageSize;
            var postList = await _postService.GetPagedPostsAsync(pagesize, page);

            int postCount = memoryCache.GetOrCreate(StaticCacheKeys.PostCount, entry => _postService.CountVisiblePosts().Item);

            var postsAsIPagedList = new StaticPagedList <PostListItem>(postList, page, pagesize, postCount);

            return(View(postsAsIPagedList));
        }