From b545da19b77c0e297eaf16f0877d43de4a0fef33 Mon Sep 17 00:00:00 2001 From: Maxime Adler Date: Thu, 10 Apr 2025 15:21:13 +0200 Subject: [PATCH] Fix message --- .../GameIdeas.Shared/Exceptions/NotFoundException.cs | 6 +----- .../GameIdeas.WebAPI/Controllers/GameController.cs | 4 ++-- .../Server/GameIdeas.WebAPI/Services/GameService.cs | 9 +++------ 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/src/GameIdeas/GameIdeas.Shared/Exceptions/NotFoundException.cs b/src/GameIdeas/GameIdeas.Shared/Exceptions/NotFoundException.cs index 7467e55..027b57d 100644 --- a/src/GameIdeas/GameIdeas.Shared/Exceptions/NotFoundException.cs +++ b/src/GameIdeas/GameIdeas.Shared/Exceptions/NotFoundException.cs @@ -1,7 +1,3 @@ namespace GameIdeas.Shared.Exceptions; -public class NotFoundException : Exception -{ - public NotFoundException(string msg, Exception? innerException = null) : base(msg, innerException) - { } -} +public class NotFoundException(string msg, Exception? innerException = null) : Exception(msg, innerException); diff --git a/src/GameIdeas/Server/GameIdeas.WebAPI/Controllers/GameController.cs b/src/GameIdeas/Server/GameIdeas.WebAPI/Controllers/GameController.cs index 382fb85..44458e4 100644 --- a/src/GameIdeas/Server/GameIdeas.WebAPI/Controllers/GameController.cs +++ b/src/GameIdeas/Server/GameIdeas.WebAPI/Controllers/GameController.cs @@ -10,8 +10,8 @@ namespace GameIdeas.WebAPI.Controllers; public class GameController(GameService gameService) : Controller { [HttpGet("Search")] - public async Task> FetchGames([FromQuery] GameFilterDto filter) + public async Task> FetchGames([FromQuery] PaggingDto pagging) { - return await gameService.GetGames(filter); + return await gameService.GetGames(pagging); } } diff --git a/src/GameIdeas/Server/GameIdeas.WebAPI/Services/GameService.cs b/src/GameIdeas/Server/GameIdeas.WebAPI/Services/GameService.cs index de768e3..98674f6 100644 --- a/src/GameIdeas/Server/GameIdeas.WebAPI/Services/GameService.cs +++ b/src/GameIdeas/Server/GameIdeas.WebAPI/Services/GameService.cs @@ -42,12 +42,9 @@ public class GameService(GameIdeasContext context, IMapper mapper) .Include(g => g.GameDevelopers).ThenInclude(p => p.Developer) .FirstOrDefaultAsync(g => g.Id == gameId); - if (game == null) - { - throw new NotFoundException($"[{typeof(Game).Name}] with ID {gameId} has not been found in context"); - } - - return mapper.Map(game); + return game == null + ? throw new NotFoundException($"[{typeof(Game).Name}] with ID {gameId} has not been found in context") + : mapper.Map(game); } public async Task CreateGame(GameDto gameDto)