From 471ea08f465ba8415938796a74a73b93a8eaf94a Mon Sep 17 00:00:00 2001 From: Valentin Virot Date: Sun, 20 Jul 2025 16:15:11 +0200 Subject: [PATCH] Fixed League related routes --- .../UpdateConnectedPlayerCommandHandler.cs | 4 +++- .../UpdateTournamentPictureCommandHandler.cs | 4 ---- .../GetTournamentLogo/GetTournamentLogoQueryHandler.cs | 4 +--- .../UpdatePlayerSummonerCommandHandler.cs | 3 +-- .../RiotGames/Implementations/LeagueV4Service.cs | 4 ++-- GameOn.External/RiotGames/Interfaces/ILeagueService.cs | 6 +++--- 6 files changed, 10 insertions(+), 15 deletions(-) diff --git a/GameOn.Application/Common/Players/Commands/UpdateConnectedPlayer/UpdateConnectedPlayerCommandHandler.cs b/GameOn.Application/Common/Players/Commands/UpdateConnectedPlayer/UpdateConnectedPlayerCommandHandler.cs index 59ce02d..69fe0cd 100644 --- a/GameOn.Application/Common/Players/Commands/UpdateConnectedPlayer/UpdateConnectedPlayerCommandHandler.cs +++ b/GameOn.Application/Common/Players/Commands/UpdateConnectedPlayer/UpdateConnectedPlayerCommandHandler.cs @@ -70,7 +70,9 @@ public async Task Handle(UpdateConnectedPlayerCommand request, Cancellat if (summonerIdFromRiot is not null) { - playerInDb.LolSummonerId = summonerIdFromRiot.SummonerId; + playerInDb.LolSummonerLevel = summonerIdFromRiot.SummonerLevel; + playerInDb.LolIconId = summonerIdFromRiot.ProfileIconId; + playerInDb.LolRefreshedOn = DateTime.Now; } } } diff --git a/GameOn.Application/FIFA/Tournaments/Commands/UpdateTournamentPicture/UpdateTournamentPictureCommandHandler.cs b/GameOn.Application/FIFA/Tournaments/Commands/UpdateTournamentPicture/UpdateTournamentPictureCommandHandler.cs index b884ccf..bb35555 100644 --- a/GameOn.Application/FIFA/Tournaments/Commands/UpdateTournamentPicture/UpdateTournamentPictureCommandHandler.cs +++ b/GameOn.Application/FIFA/Tournaments/Commands/UpdateTournamentPicture/UpdateTournamentPictureCommandHandler.cs @@ -2,14 +2,10 @@ // Copyright (c) LeadOn's Corp'. All rights reserved. // -using GameOn.Application.FIFA.Tournaments.Queries.GetTournamentById; - namespace GameOn.Application.FIFA.Tournaments.Commands.UpdateTournamentPicture { - using GameOn.Application.Common.Players.Queries.GetPlayerById; using GameOn.Common.Exceptions; using GameOn.Common.Interfaces; - using GameOn.Domain; using GameOn.External.NetworkStorage.Interfaces; using MediatR; using Microsoft.EntityFrameworkCore; diff --git a/GameOn.Application/FIFA/Tournaments/Queries/GetTournamentLogo/GetTournamentLogoQueryHandler.cs b/GameOn.Application/FIFA/Tournaments/Queries/GetTournamentLogo/GetTournamentLogoQueryHandler.cs index a00e01f..f1f4e93 100644 --- a/GameOn.Application/FIFA/Tournaments/Queries/GetTournamentLogo/GetTournamentLogoQueryHandler.cs +++ b/GameOn.Application/FIFA/Tournaments/Queries/GetTournamentLogo/GetTournamentLogoQueryHandler.cs @@ -2,11 +2,9 @@ // Copyright (c) LeadOn's Corp'. All rights reserved. // -using GameOn.Application.FIFA.Tournaments.Queries.GetTournamentById; - namespace GameOn.Application.FIFA.Tournaments.Queries.GetTournamentLogo { - using GameOn.Application.Common.Players.Queries.GetPlayerById; + using GameOn.Application.FIFA.Tournaments.Queries.GetTournamentById; using GameOn.Common.DTOs; using GameOn.Common.Exceptions; using GameOn.External.NetworkStorage.Interfaces; diff --git a/GameOn.Application/LeagueOfLegends/Summoners/Command/UpdatePlayerSummoner/UpdatePlayerSummonerCommandHandler.cs b/GameOn.Application/LeagueOfLegends/Summoners/Command/UpdatePlayerSummoner/UpdatePlayerSummonerCommandHandler.cs index c0329de..ede2055 100644 --- a/GameOn.Application/LeagueOfLegends/Summoners/Command/UpdatePlayerSummoner/UpdatePlayerSummonerCommandHandler.cs +++ b/GameOn.Application/LeagueOfLegends/Summoners/Command/UpdatePlayerSummoner/UpdatePlayerSummonerCommandHandler.cs @@ -61,13 +61,12 @@ public async Task Handle(UpdatePlayerSummonerCommand request, Cancellati if (summonerIdFromRiot is not null) { - playerInDb.LolSummonerId = summonerIdFromRiot.SummonerId; playerInDb.LolSummonerLevel = summonerIdFromRiot.SummonerLevel; playerInDb.LolIconId = summonerIdFromRiot.ProfileIconId; playerInDb.LolRefreshedOn = DateTime.Now; // Updating player Rank - var playerRank = await this.leagueService.GetLeagueEntries(summonerIdFromRiot.SummonerId, cancellationToken); + var playerRank = await this.leagueService.GetLeagueEntries(playerInDb.RiotGamesPUUID, cancellationToken); if (playerRank is not null) { diff --git a/GameOn.External/RiotGames/Implementations/LeagueV4Service.cs b/GameOn.External/RiotGames/Implementations/LeagueV4Service.cs index 6471ca0..41e2d73 100644 --- a/GameOn.External/RiotGames/Implementations/LeagueV4Service.cs +++ b/GameOn.External/RiotGames/Implementations/LeagueV4Service.cs @@ -25,9 +25,9 @@ public LeagueV4Service(HttpClient client) } /// - public async Task> GetLeagueEntries(string summonerId, CancellationToken cancellationToken) + public async Task> GetLeagueEntries(string puuid, CancellationToken cancellationToken) { - var request = new HttpRequestMessage(HttpMethod.Get, $"https://{Environment.GetEnvironmentVariable("RIOT_GAMES_SUMMONER_API_ROUTE")}/lol/league/v4/entries/by-summoner/{summonerId}?api_key={Environment.GetEnvironmentVariable("RIOT_GAMES_API_KEY")}"); + var request = new HttpRequestMessage(HttpMethod.Get, $"https://{Environment.GetEnvironmentVariable("RIOT_GAMES_SUMMONER_API_ROUTE")}/lol/league/v4/entries/by-puuid/{puuid}?api_key={Environment.GetEnvironmentVariable("RIOT_GAMES_API_KEY")}"); #pragma warning disable CS8603 // Existence possible d'un retour de référence null. return await RunRequest>(this.client, request, cancellationToken); #pragma warning restore CS8603 // Existence possible d'un retour de référence null diff --git a/GameOn.External/RiotGames/Interfaces/ILeagueService.cs b/GameOn.External/RiotGames/Interfaces/ILeagueService.cs index cbd395a..0316e4a 100644 --- a/GameOn.External/RiotGames/Interfaces/ILeagueService.cs +++ b/GameOn.External/RiotGames/Interfaces/ILeagueService.cs @@ -12,11 +12,11 @@ namespace GameOn.External.RiotGames.Interfaces public interface ILeagueService { /// - /// Gets League Entries by Summoner's ID. + /// Gets League Entries by its PUUID. /// - /// Summoner ID. + /// PUUID ID. /// . /// . - Task> GetLeagueEntries(string summonerId, CancellationToken cancellationToken); + Task> GetLeagueEntries(string puuid, CancellationToken cancellationToken); } }