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",
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user