Init
This commit is contained in:
32
Prefab.Web.Client/Pages/Categories.razor.cs
Normal file
32
Prefab.Web.Client/Pages/Categories.razor.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
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; } = [];
|
||||
}
|
||||
Reference in New Issue
Block a user