From 8f28d9a0eece91f87d2a96bd03d664aa3e0cdbf7 Mon Sep 17 00:00:00 2001 From: Rain Date: Sat, 17 Aug 2024 19:03:02 +0200 Subject: [PATCH] fix: Reject pending table registrations when a new registration is made (#159) * fix: Reject pending table registrations when a new registration is made * fix: Remove AsNoTracking() --- .../ArtistsAlley/TableRegistrationService.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/Eurofurence.App.Server.Services/ArtistsAlley/TableRegistrationService.cs b/src/Eurofurence.App.Server.Services/ArtistsAlley/TableRegistrationService.cs index a08ef61b..0f793a2e 100644 --- a/src/Eurofurence.App.Server.Services/ArtistsAlley/TableRegistrationService.cs +++ b/src/Eurofurence.App.Server.Services/ArtistsAlley/TableRegistrationService.cs @@ -62,6 +62,19 @@ public override async Task FindOneAsync( public async Task RegisterTableAsync(ClaimsPrincipal user, TableRegistrationRequest request) { + var subject = user.GetSubject(); + var activeRegistrations = await _appDbContext.TableRegistrations + .Where(x => + x.OwnerUid == subject && + x.State == TableRegistrationRecord.RegistrationStateEnum.Pending) + .ToListAsync(); + + foreach (var registration in activeRegistrations) + { + registration.ChangeState(TableRegistrationRecord.RegistrationStateEnum.Rejected, subject); + registration.Touch(); + } + var image = await _imageService.FindOneAsync(request.ImageId); await _imageService.EnforceMaximumDimensionsAsync(image, 1500, 1500);