コード例 #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
ファイル: PostController.cs プロジェクト: 286116920/Moonglade
        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
ファイル: PostController.cs プロジェクト: xingx001/Moonglade
        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
ファイル: PostController.cs プロジェクト: Twtcer/Moonglade
        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));
        }