feature/apply-filter (#18)
Co-authored-by: Maxime Adler <madler@sqli.com> Reviewed-on: #18
This commit was merged in pull request #18.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using GameIdeas.BlazorApp.Services;
|
||||
using GameIdeas.BlazorApp.Pages.Games.Filter;
|
||||
using GameIdeas.BlazorApp.Services;
|
||||
using GameIdeas.BlazorApp.Shared.Constants;
|
||||
using GameIdeas.BlazorApp.Shared.Exceptions;
|
||||
using GameIdeas.Resources;
|
||||
@@ -8,7 +9,7 @@ namespace GameIdeas.BlazorApp.Pages.Games.Gateways;
|
||||
|
||||
public class GameGateway(IHttpClientService httpClientService) : IGameGateway
|
||||
{
|
||||
public async Task<int> CreateGame(GameDto game)
|
||||
public async Task<int> CreateGame(GameDetailDto game)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -34,11 +35,26 @@ public class GameGateway(IHttpClientService httpClientService) : IGameGateway
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<GameDto>> FetchGames(PaggingDto pagging)
|
||||
public async Task<IEnumerable<GameDto>> FetchGames(GameFilterParams filterParams, int currentPage)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = await httpClientService.FetchDataAsync<IEnumerable<GameDto>>(Endpoints.Game.Fetch(pagging));
|
||||
GameFilterDto filter = new()
|
||||
{
|
||||
CurrentPage = currentPage,
|
||||
Title = filterParams.Title,
|
||||
MaxInterest = filterParams.MaxInterest,
|
||||
MinInterest = filterParams.MinInterest,
|
||||
StorageSpaces = filterParams.StorageSpaceIds,
|
||||
DeveloperIds = filterParams.Developers?.Select(d => d.Id ?? 0).ToList(),
|
||||
PublisherIds = filterParams.Publishers?.Select(d => d.Id ?? 0).ToList(),
|
||||
PlatformIds = filterParams.Platforms?.Select(d => d.Id ?? 0).ToList(),
|
||||
PropertyIds = filterParams.Properties?.Select(d => d.Id ?? 0).ToList(),
|
||||
ReleaseYears = filterParams.ReleaseYears,
|
||||
TagIds = filterParams.Tags?.Select(d => d.Id ?? 0).ToList(),
|
||||
};
|
||||
|
||||
var result = await httpClientService.FetchDataAsync<IEnumerable<GameDto>>(Endpoints.Game.Fetch(filter));
|
||||
return result ?? throw new InvalidOperationException(ResourcesKey.ErrorFetchGames);
|
||||
}
|
||||
catch (Exception)
|
||||
|
||||
Reference in New Issue
Block a user