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; }
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)); }
public async Task <IActionResult> Archive([FromServices] IBlogArchiveService blogArchiveService) { var archives = await blogArchiveService.ListAsync(); return(View(archives)); }