Add frontend creation game (#13)
Reviewed-on: #13
This commit was merged in pull request #13.
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
using GameIdeas.BlazorApp.Services;
|
||||
using GameIdeas.BlazorApp.Shared.Constants;
|
||||
using GameIdeas.BlazorApp.Shared.Exceptions;
|
||||
using GameIdeas.Resources;
|
||||
using GameIdeas.Shared.Dto;
|
||||
|
||||
namespace GameIdeas.BlazorApp.Pages.Games.Gateways;
|
||||
|
||||
public class GameGateway(IHttpClientService httpClientService) : IGameGateway
|
||||
{
|
||||
public async Task<CategoriesDto> FetchCategories()
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = await httpClientService.FetchDataAsync<CategoriesDto>(Endpoints.Category.AllCategories);
|
||||
|
||||
return result ?? throw new InvalidOperationException(ResourcesKey.ErrorFetchCategories);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw new CategoryNotFoundException(ResourcesKey.ErrorFetchCategories);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user