Files
prefab-page-detail/Prefab.Web.Client/Pages/Categories.razor.cs
2025-10-27 17:39:18 -04:00

33 lines
823 B
C#

using Microsoft.AspNetCore.Components;
using Prefab.Web.Client.Models;
using Prefab.Web.Client.Services;
namespace Prefab.Web.Client.Pages;
public class CategoriesComponent : ResultComponentBase<CategoriesPageModel>
{
[Inject]
protected ICategoriesPageService PageService { get; set; } = null!;
protected CategoriesPageModel Page { get; set; } = new();
protected override async Task OnInitializedAsync()
{
var result = await Execute(PageService.GetPage, CancellationToken.None);
if (result.IsSuccess && result.Value is { } value)
{
Page = value;
}
else
{
Page = new CategoriesPageModel();
}
}
}
public class CategoriesPageModel
{
public IEnumerable<CategoryListItemModel> Categories { get; set; } = [];
}