From 49e696b4f001e4c8bc26fdbc876f9542fba4256f Mon Sep 17 00:00:00 2001 From: Valentin Virot Date: Fri, 2 May 2025 16:28:00 +0200 Subject: [PATCH] Fixed an issue with player update --- .../UpdateConnectedPlayerCommandHandler.cs | 12 ++++++++++-- .../UpdatePlayer/UpdatePlayerCommandHandler.cs | 2 +- GameOn.Common/DTOs/UpdatePlayerDto.cs | 2 +- .../Controllers/Common/PlayerController.cs | 4 ++-- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/GameOn.Application/Common/Players/Commands/UpdateConnectedPlayer/UpdateConnectedPlayerCommandHandler.cs b/GameOn.Application/Common/Players/Commands/UpdateConnectedPlayer/UpdateConnectedPlayerCommandHandler.cs index da23ec7..b9d6136 100644 --- a/GameOn.Application/Common/Players/Commands/UpdateConnectedPlayer/UpdateConnectedPlayerCommandHandler.cs +++ b/GameOn.Application/Common/Players/Commands/UpdateConnectedPlayer/UpdateConnectedPlayerCommandHandler.cs @@ -35,7 +35,7 @@ public UpdateConnectedPlayerCommandHandler(IApplicationDbContext context, IAccou /// public async Task Handle(UpdateConnectedPlayerCommand request, CancellationToken cancellationToken) { - var playerInDb = await this.context.Players.FirstOrDefaultAsync(x => x.KeycloakId == request.Player.KeycloakId); + var playerInDb = await this.context.Players.FirstOrDefaultAsync(x => x.KeycloakId == request.Player.KeycloakId, cancellationToken); if (playerInDb == null) { @@ -44,7 +44,15 @@ public async Task Handle(UpdateConnectedPlayerCommand request, Cancellat playerInDb.FullName = request.Player.FullName; playerInDb.Nickname = request.Player.Nickname; - playerInDb.ProfilePictureUrl = request.Player.ProfilePictureUrl; + + if (request.Player.ProfilePictureUrl is not null && request.Player.ProfilePictureUrl != string.Empty) + { + playerInDb.ProfilePictureUrl = request.Player.ProfilePictureUrl; + } + else + { + playerInDb.ProfilePictureUrl = "https://gameon.valentinvirot.fr/assets/img/gameon-logo.webp"; + } if (request.Player.RiotGamesNickname is not null && request.Player.RiotGamesTagLine is not null) { diff --git a/GameOn.Application/Common/Players/Commands/UpdatePlayer/UpdatePlayerCommandHandler.cs b/GameOn.Application/Common/Players/Commands/UpdatePlayer/UpdatePlayerCommandHandler.cs index 7c3e253..a9ac645 100644 --- a/GameOn.Application/Common/Players/Commands/UpdatePlayer/UpdatePlayerCommandHandler.cs +++ b/GameOn.Application/Common/Players/Commands/UpdatePlayer/UpdatePlayerCommandHandler.cs @@ -37,7 +37,7 @@ public async Task Handle(UpdatePlayerCommand request, CancellationToken playerInDb.FullName = request.Player.FullName; playerInDb.Nickname = request.Player.Nickname; - playerInDb.ProfilePictureUrl = request.Player.ProfilePictureUrl; + playerInDb.ProfilePictureUrl = request.Player.ProfilePictureUrl ?? "https://gameon.valentinvirot.fr/assets/img/gameon-logo.webp"; playerInDb.KeycloakId = request.Player.KeycloakId; playerInDb.Archived = request.Player.Archived; diff --git a/GameOn.Common/DTOs/UpdatePlayerDto.cs b/GameOn.Common/DTOs/UpdatePlayerDto.cs index 74cd4f2..c895937 100644 --- a/GameOn.Common/DTOs/UpdatePlayerDto.cs +++ b/GameOn.Common/DTOs/UpdatePlayerDto.cs @@ -42,7 +42,7 @@ public class UpdatePlayerDto /// /// Gets or sets Profile Picture URL. /// - public string ProfilePictureUrl { get; set; } = "INVALID URL"; + public string? ProfilePictureUrl { get; set; } /// /// Gets or sets a value indicating whether the player is archived. diff --git a/GameOn.Presentation/Controllers/Common/PlayerController.cs b/GameOn.Presentation/Controllers/Common/PlayerController.cs index b9b3132..f8eae45 100644 --- a/GameOn.Presentation/Controllers/Common/PlayerController.cs +++ b/GameOn.Presentation/Controllers/Common/PlayerController.cs @@ -113,7 +113,7 @@ public async Task GetPlayerStats(int playerId, int? seasonId) } /// - /// Update user (admin only). + /// Update connected user. /// /// . /// IActionResult object. @@ -135,7 +135,7 @@ public async Task UpdateConnectedUser([FromBody] UpdatePlayerDto } /// - /// Update connected user. + /// Update user (admin only). /// /// . /// IActionResult object.