Update and delete games (#48)
All checks were successful
Game Ideas deploy / build-test-deploy (push) Successful in 1m27s
All checks were successful
Game Ideas deploy / build-test-deploy (push) Successful in 1m27s
Co-authored-by: Maxime Adler <madler@sqli.com> Reviewed-on: #48
This commit was merged in pull request #48.
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
using GameIdeas.BlazorApp.Pages.Games.Gateways;
|
||||
using GameIdeas.BlazorApp.Shared.Models;
|
||||
using GameIdeas.Shared.Dto;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
|
||||
namespace GameIdeas.BlazorApp.Shared.Components;
|
||||
|
||||
public class GameBaseComponent : ComponentBase
|
||||
{
|
||||
[Inject] protected IGameGateway GameGateway { get; set; } = default!;
|
||||
|
||||
protected Popup.Popup? ManualAddPopup;
|
||||
protected CategoriesDto? Categories;
|
||||
protected bool IsLoading = false;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
await HandleFetchCategories();
|
||||
await base.OnInitializedAsync();
|
||||
}
|
||||
|
||||
protected async Task HandleFetchCategories()
|
||||
{
|
||||
try
|
||||
{
|
||||
IsLoading = true;
|
||||
|
||||
Categories = await GameGateway.FetchCategories();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
finally
|
||||
{
|
||||
IsLoading = false;
|
||||
}
|
||||
}
|
||||
|
||||
protected void HandleAddClicked(AddType addType)
|
||||
{
|
||||
switch (addType)
|
||||
{
|
||||
case AddType.Manual:
|
||||
ManualAddPopup?.Open();
|
||||
break;
|
||||
case AddType.Auto:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
protected void HandleBackdropManualAddClicked()
|
||||
{
|
||||
ManualAddPopup?.Close();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user