fix(shared): convert GameSystem to string in SQL, guard rollback after commit

This commit is contained in:
2026-05-28 16:26:54 +03:00
parent ab38238fe8
commit 633a020212
@@ -16,6 +16,7 @@ public sealed class CreateSessionHandler(
await using var connection = await dataSource.OpenConnectionAsync(ct); await using var connection = await dataSource.OpenConnectionAsync(ct);
await using var transaction = await connection.BeginTransactionAsync(ct); await using var transaction = await connection.BeginTransactionAsync(ct);
var transactionCommitted = false;
try try
{ {
var platform = command.User.Platform.ToString(); var platform = command.User.Platform.ToString();
@@ -130,7 +131,7 @@ public sealed class CreateSessionHandler(
ScheduledAt = scheduledAt, ScheduledAt = scheduledAt,
Status = SessionStatus.Planned, Status = SessionStatus.Planned,
MaxPlayers = command.MaxPlayers, MaxPlayers = command.MaxPlayers,
System = command.System, System = command.System?.ToString(),
command.Description, command.Description,
command.Format, command.Format,
DurationMinutes = command.DurationMinutes, DurationMinutes = command.DurationMinutes,
@@ -142,6 +143,7 @@ public sealed class CreateSessionHandler(
} }
await transaction.CommitAsync(ct); await transaction.CommitAsync(ct);
transactionCommitted = true;
var view = SessionBatchViewBuilder.Build(command.Title, sessions, Array.Empty<ParticipantBatchDto>()); var view = SessionBatchViewBuilder.Build(command.Title, sessions, Array.Empty<ParticipantBatchDto>());
@@ -155,7 +157,10 @@ public sealed class CreateSessionHandler(
} }
catch catch
{ {
await transaction.RollbackAsync(ct); if (!transactionCommitted)
{
await transaction.RollbackAsync(ct);
}
throw; throw;
} }
} }