From aa4533269f80d0965f13f9ffe58d03fbb3c1d82f Mon Sep 17 00:00:00 2001 From: dingo Date: Fri, 20 Mar 2026 17:12:05 -0400 Subject: [PATCH] Add Delete action to admin Custom Lobbies page; fix CS0136 in CollectionGetCardsHandler - Admin CustomLobbiesPage: add Delete button (hard DB remove with confirm dialog) shown on every lobby row; Cancel remains for Open/Full lobbies only - CollectionGetCardsHandler: rename inner-scope variables (groupedTotal/groupedDtos) to fix CS0136 compiler error from same-name variables in nested vs outer scope Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude Co-Authored-By: Happy --- .../Pages/Game/CustomLobbiesPage.razor | 20 ++++++++++++++++++- .../Handlers/CollectionGetCardsHandler.cs | 8 ++++---- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/Server/src/SOR.Admin/Components/Pages/Game/CustomLobbiesPage.razor b/Server/src/SOR.Admin/Components/Pages/Game/CustomLobbiesPage.razor index d85a42a..140969f 100644 --- a/Server/src/SOR.Admin/Components/Pages/Game/CustomLobbiesPage.razor +++ b/Server/src/SOR.Admin/Components/Pages/Game/CustomLobbiesPage.razor @@ -4,6 +4,7 @@ @using SOR.Database.Enums @using Microsoft.EntityFrameworkCore @inject GameDbContext GameDb +@inject IJSRuntime JS Custom Lobbies — SOR Admin @@ -113,7 +114,7 @@ else — } - + @if (lobby.Status == CustomLobbyStatus.Open || lobby.Status == CustomLobbyStatus.Full) { } @@ -174,6 +180,18 @@ else await LoadAsync(); } + private async Task DeleteLobbyAsync(Guid lobbyId) + { + var confirmed = await JS.InvokeAsync("confirm", $"Permanently delete lobby {lobbyId.ToString()[..8]}…? This cannot be undone."); + if (!confirmed) return; + + var lobby = await GameDb.CustomLobbies.FindAsync(lobbyId); + if (lobby is null) return; + GameDb.CustomLobbies.Remove(lobby); + await GameDb.SaveChangesAsync(); + await LoadAsync(); + } + private static string StatusBadge(CustomLobbyStatus status) => status switch { CustomLobbyStatus.Open => "bg-primary", diff --git a/Server/src/SOR.Collection/Handlers/CollectionGetCardsHandler.cs b/Server/src/SOR.Collection/Handlers/CollectionGetCardsHandler.cs index 157c276..31ff5c1 100644 --- a/Server/src/SOR.Collection/Handlers/CollectionGetCardsHandler.cs +++ b/Server/src/SOR.Collection/Handlers/CollectionGetCardsHandler.cs @@ -84,15 +84,15 @@ internal sealed class CollectionGetCardsHandler : CollectionHandlerBase, IMessag IsTradeable = g.Any(x => x.IsTradeable), }); - int total = await grouped.CountAsync(cancellationToken); + int groupedTotal = await grouped.CountAsync(cancellationToken); var pageRows = await grouped .OrderBy(x => x.CardDefinitionId) // or by AcquiredAt if you prefer .Skip(skip) .Take(pageSize) .ToListAsync(cancellationToken); - - var dtos = pageRows.Select(x => new PlayerCardDto( + + var groupedDtos = pageRows.Select(x => new PlayerCardDto( PlayerCardId: x.PlayerCardId, CardDefinitionId: x.CardDefinitionId, IsFoil: x.IsFoil, @@ -104,7 +104,7 @@ internal sealed class CollectionGetCardsHandler : CollectionHandlerBase, IMessag return ServerMessage.Reply( "collection.get_cards.ack", message.Seq, - new GetCardsResponse(dtos, total, page, pageSize)); + new GetCardsResponse(groupedDtos, groupedTotal, page, pageSize)); } }