feat: harden auth ops and deployment baseline
This commit is contained in:
@@ -1,12 +1,13 @@
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using TaxBaik.Application.Services;
|
||||
using TaxBaik.Domain.Entities;
|
||||
using TaxBaik.Web.Services;
|
||||
|
||||
namespace TaxBaik.Web.Pages.Blog;
|
||||
|
||||
public class BlogIndexModel : PageModel
|
||||
{
|
||||
private readonly IApiClient _apiClient;
|
||||
private readonly BlogService _blogService;
|
||||
private readonly CategoryService _categoryService;
|
||||
|
||||
public List<BlogPost> Posts { get; set; } = [];
|
||||
public List<Category> Categories { get; set; } = [];
|
||||
@@ -15,9 +16,10 @@ public class BlogIndexModel : PageModel
|
||||
public int? SelectedCategoryId { get; set; }
|
||||
private const int PageSize = 12;
|
||||
|
||||
public BlogIndexModel(IApiClient apiClient)
|
||||
public BlogIndexModel(BlogService blogService, CategoryService categoryService)
|
||||
{
|
||||
_apiClient = apiClient;
|
||||
_blogService = blogService;
|
||||
_categoryService = categoryService;
|
||||
}
|
||||
|
||||
public async Task OnGetAsync(int page = 1, int? categoryId = null)
|
||||
@@ -27,15 +29,11 @@ public class BlogIndexModel : PageModel
|
||||
CurrentPage = page;
|
||||
SelectedCategoryId = categoryId;
|
||||
|
||||
var categories = await _apiClient.GetAsync<List<Category>>("category");
|
||||
Categories = categories ?? [];
|
||||
Categories = (await _categoryService.GetAllAsync()).ToList();
|
||||
|
||||
var blogsResponse = await _apiClient.GetAsync<BlogApiResponse>($"blog?page={page}&pageSize={PageSize}");
|
||||
if (blogsResponse != null)
|
||||
{
|
||||
Posts = blogsResponse.Data ?? [];
|
||||
TotalPages = (blogsResponse.Total + PageSize - 1) / PageSize;
|
||||
}
|
||||
var (posts, total) = await _blogService.GetPublishedPagedAsync(page, PageSize, categoryId);
|
||||
Posts = posts.ToList();
|
||||
TotalPages = (total + PageSize - 1) / PageSize;
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user