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 <noreply@anthropic.com> Co-Authored-By: Happy <yesreply@happy.engineering>
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
@using SOR.Database.Enums
|
||||
@using Microsoft.EntityFrameworkCore
|
||||
@inject GameDbContext GameDb
|
||||
@inject IJSRuntime JS
|
||||
|
||||
<PageTitle>Custom Lobbies — SOR Admin</PageTitle>
|
||||
|
||||
@@ -113,7 +114,7 @@ else
|
||||
<span class="text-muted">—</span>
|
||||
}
|
||||
</td>
|
||||
<td>
|
||||
<td class="d-flex gap-1">
|
||||
@if (lobby.Status == CustomLobbyStatus.Open || lobby.Status == CustomLobbyStatus.Full)
|
||||
{
|
||||
<button class="btn btn-outline-danger btn-sm"
|
||||
@@ -122,6 +123,11 @@ else
|
||||
Cancel
|
||||
</button>
|
||||
}
|
||||
<button class="btn btn-danger btn-sm"
|
||||
@onclick="() => DeleteLobbyAsync(lobby.Id)"
|
||||
title="Permanently delete this lobby record">
|
||||
Delete
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
@@ -174,6 +180,18 @@ else
|
||||
await LoadAsync();
|
||||
}
|
||||
|
||||
private async Task DeleteLobbyAsync(Guid lobbyId)
|
||||
{
|
||||
var confirmed = await JS.InvokeAsync<bool>("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",
|
||||
|
||||
Reference in New Issue
Block a user