diff --git a/LeaderboardBackend/Controllers/LeaderboardsController.cs b/LeaderboardBackend/Controllers/LeaderboardsController.cs index 20045bf6..6d32744a 100644 --- a/LeaderboardBackend/Controllers/LeaderboardsController.cs +++ b/LeaderboardBackend/Controllers/LeaderboardsController.cs @@ -13,13 +13,11 @@ public class LeaderboardsController : ApiController { private readonly ILeaderboardService _leaderboardService; - public LeaderboardsController(ILeaderboardService leaderboardService) - { + public LeaderboardsController(ILeaderboardService leaderboardService) => _leaderboardService = leaderboardService; - } [AllowAnonymous] - [HttpGet("{id:long}")] + [HttpGet("/api/leaderboard/{id:long}")] [SwaggerOperation("Gets a leaderboard by its ID.")] [SwaggerResponse(200)] [SwaggerResponse(404)] diff --git a/LeaderboardBackend/Services/Impl/LeaderboardService.cs b/LeaderboardBackend/Services/Impl/LeaderboardService.cs index e0335f84..1f702c89 100644 --- a/LeaderboardBackend/Services/Impl/LeaderboardService.cs +++ b/LeaderboardBackend/Services/Impl/LeaderboardService.cs @@ -12,17 +12,14 @@ public LeaderboardService(ApplicationContext applicationContext) _applicationContext = applicationContext; } - public async Task GetLeaderboard(long id) - { - return await _applicationContext.Leaderboards.FindAsync(id); - } + public async Task GetLeaderboard(long id) => + await _applicationContext.Leaderboards + .FirstOrDefaultAsync(board => board.Id == id); - public Task GetLeaderboardBySlug(string slug) - { - return _applicationContext.Leaderboards + public Task GetLeaderboardBySlug(string slug) => + _applicationContext.Leaderboards .AsNoTracking() .FirstOrDefaultAsync(x => x.Slug == slug); - } // FIXME: Paginate this public async Task> GetLeaderboards(long[]? ids = null) diff --git a/LeaderboardBackend/openapi.json b/LeaderboardBackend/openapi.json index e6b6c2cd..c7c962b8 100644 --- a/LeaderboardBackend/openapi.json +++ b/LeaderboardBackend/openapi.json @@ -453,7 +453,7 @@ } } }, - "/api/Leaderboards/{id}": { + "/api/leaderboard/{id}": { "get": { "tags": [ "Leaderboards"