31 lines
647 B
C#
31 lines
647 B
C#
using Microsoft.AspNetCore.Mvc.RazorPages;
|
|
using TaxBaik.Application.Services;
|
|
using TaxBaik.Domain.Entities;
|
|
|
|
namespace TaxBaik.Web.Pages;
|
|
|
|
public class IndexModel : PageModel
|
|
{
|
|
private readonly BlogService _blogService;
|
|
|
|
public List<BlogPost> RecentPosts { get; set; } = [];
|
|
|
|
public IndexModel(BlogService blogService)
|
|
{
|
|
_blogService = blogService;
|
|
}
|
|
|
|
public async Task OnGetAsync()
|
|
{
|
|
try
|
|
{
|
|
var (posts, _) = await _blogService.GetPublishedPagedAsync(1, 3);
|
|
RecentPosts = posts.ToList();
|
|
}
|
|
catch
|
|
{
|
|
RecentPosts = [];
|
|
}
|
|
}
|
|
}
|