コード例 #1
0
 public HomeController(
     IPostService postService,
     IPageService pageService,
     ITagService tagService,
     IBlogArchiveService blogArchiveService,
     IBlogCache cache,
     IBlogConfig blogConfig,
     ILogger <HomeController> logger,
     IOptions <AppSettings> settingsOptions)
 {
     _postService        = postService;
     _pageService        = pageService;
     _tagService         = tagService;
     _blogArchiveService = blogArchiveService;
     _cache      = cache;
     _blogConfig = blogConfig;
     _logger     = logger;
     _settings   = settingsOptions.Value;
 }
コード例 #2
0
        public async Task <IActionResult> ArchiveList([FromServices] IBlogArchiveService blogArchiveService, int year, int?month)
        {
            if (year > DateTime.UtcNow.Year)
            {
                return(BadRequest());
            }

            IReadOnlyList <PostDigest> model;

            if (month is not null)
            {
                // {year}/{month}
                ViewBag.ArchiveInfo = $"{year}.{month}";
                model = await blogArchiveService.ListPostsAsync(year, month.Value);
            }
            else
            {
                // {year}
                ViewBag.ArchiveInfo = $"{year}";
                model = await blogArchiveService.ListPostsAsync(year);
            }

            return(View(model));
        }
コード例 #3
0
        public async Task <IActionResult> Archive([FromServices] IBlogArchiveService blogArchiveService)
        {
            var archives = await blogArchiveService.ListAsync();

            return(View(archives));
        }