Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public UpdateConnectedPlayerCommandHandler(IApplicationDbContext context, IAccou
/// <inheritdoc />
public async Task<Player> 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)
{
Expand All @@ -44,7 +44,15 @@ public async Task<Player> 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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public async Task<Player> 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;

Expand Down
2 changes: 1 addition & 1 deletion GameOn.Common/DTOs/UpdatePlayerDto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class UpdatePlayerDto
/// <summary>
/// Gets or sets Profile Picture URL.
/// </summary>
public string ProfilePictureUrl { get; set; } = "INVALID URL";
public string? ProfilePictureUrl { get; set; }

/// <summary>
/// Gets or sets a value indicating whether the player is archived.
Expand Down
4 changes: 2 additions & 2 deletions GameOn.Presentation/Controllers/Common/PlayerController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public async Task<IActionResult> GetPlayerStats(int playerId, int? seasonId)
}

/// <summary>
/// Update user (admin only).
/// Update connected user.
/// </summary>
/// <param name="update"><see cref="UpdatePlayerDto"/>.</param>
/// <returns>IActionResult object.</returns>
Expand All @@ -135,7 +135,7 @@ public async Task<IActionResult> UpdateConnectedUser([FromBody] UpdatePlayerDto
}

/// <summary>
/// Update connected user.
/// Update user (admin only).
/// </summary>
/// <param name="update"><see cref="UpdatePlayerDto"/>.</param>
/// <returns>IActionResult object.</returns>
Expand Down