using System.Collections.Generic; using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; using Volo.Blogging.Blogs; using Volo.Blogging.Posts; using Volo.Blogging.Tagging; using Volo.Blogging.Tagging.Dtos; namespace Volo.Blogging.Pages.Blog.Posts { public class IndexModel : PageModel { private readonly IPostAppService _postAppService; private readonly IBlogAppService _blogAppService; private readonly ITagAppService _tagAppService; [BindProperty(SupportsGet = true)] public string BlogShortName { get; set; } [BindProperty(SupportsGet = true)] public string TagName { get; set; } public IReadOnlyList Posts { get; set; } public IReadOnlyList PopularTags { get; set; } public IndexModel(IPostAppService postAppService, IBlogAppService blogAppService, ITagAppService tagAppService) { _postAppService = postAppService; _blogAppService = blogAppService; _tagAppService = tagAppService; } public async Task OnGetAsync() { var blog = await _blogAppService.GetByShortNameAsync(BlogShortName); Posts = (await _postAppService.GetListByBlogIdAndTagName(blog.Id, TagName)).Items; PopularTags = (await _tagAppService.GetPopularTags(new GetPopularTagsInput {ResultCount = 10})); } } }