Add winner archive, host image upload and live demo data
Deliver the demo-ready feature set and seed data so the live site can be presented end to end: - Winner archive: ArchivedWinner domain, admin CRUD endpoints/view/manager and public archive surface, backed by AddArchivedWinners migration. - Host presentation: host image upload and artist name on SiteSettings with public image endpoint and supporting migrations. - Clip submissions: idempotent table-ensure migration plus current-season demo clips for review workflows. - Demo seed data: sponsors, share links and 2025 archived winners, with a guarded RemoveDemoSeasons cleanup; all seeds guard against real data. - EnsureRuntimeSchemaParity migration to align runtime schema defensively. - Admin/home UI refinements; remove unused team role permissions modal and dead share-quick-links code. All seed and schema migrations are idempotent (IF NOT EXISTS / ON CONFLICT) and skip when real season data is present. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -193,6 +193,34 @@ public static partial class AdminSeasonManagementEndpoints
|
||||
return Results.Ok(new { saved = true, candidateId = candidate.Id });
|
||||
}
|
||||
|
||||
private static async Task<IResult> GetCandidateDeletePreview(
|
||||
int candidateId,
|
||||
AwardsDbContext db,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
var candidate = await db.Candidates
|
||||
.AsNoTracking()
|
||||
.FirstOrDefaultAsync(item => item.Id == candidateId, cancellationToken);
|
||||
if (candidate is null)
|
||||
{
|
||||
return Results.NotFound();
|
||||
}
|
||||
|
||||
var nominationCount = await db.Nominations.CountAsync(item => item.CandidateId == candidateId, cancellationToken);
|
||||
var clipCount = await db.ClipSubmissions.CountAsync(item => item.CandidateId == candidateId, cancellationToken);
|
||||
var voteCount = await db.VoteEntries.CountAsync(item => item.CandidateId == candidateId, cancellationToken);
|
||||
var resultCount = await db.Results.CountAsync(item => item.CandidateId == candidateId, cancellationToken);
|
||||
|
||||
return Results.Ok(new
|
||||
{
|
||||
candidateId,
|
||||
nominationCount,
|
||||
clipCount,
|
||||
voteCount,
|
||||
resultCount,
|
||||
});
|
||||
}
|
||||
|
||||
private static async Task<IResult> DeleteCandidate(
|
||||
HttpContext context,
|
||||
int candidateId,
|
||||
@@ -206,6 +234,38 @@ public static partial class AdminSeasonManagementEndpoints
|
||||
return Results.NotFound();
|
||||
}
|
||||
|
||||
var linkedNominations = await db.Nominations
|
||||
.Where(item => item.CandidateId == candidateId)
|
||||
.ToListAsync(context.RequestAborted);
|
||||
if (linkedNominations.Count > 0)
|
||||
{
|
||||
db.Nominations.RemoveRange(linkedNominations);
|
||||
}
|
||||
|
||||
var linkedClips = await db.ClipSubmissions
|
||||
.Where(item => item.CandidateId == candidateId)
|
||||
.ToListAsync(context.RequestAborted);
|
||||
if (linkedClips.Count > 0)
|
||||
{
|
||||
db.ClipSubmissions.RemoveRange(linkedClips);
|
||||
}
|
||||
|
||||
var linkedVoteEntries = await db.VoteEntries
|
||||
.Where(item => item.CandidateId == candidateId)
|
||||
.ToListAsync(context.RequestAborted);
|
||||
if (linkedVoteEntries.Count > 0)
|
||||
{
|
||||
db.VoteEntries.RemoveRange(linkedVoteEntries);
|
||||
}
|
||||
|
||||
var linkedResults = await db.Results
|
||||
.Where(item => item.CandidateId == candidateId)
|
||||
.ToListAsync(context.RequestAborted);
|
||||
if (linkedResults.Count > 0)
|
||||
{
|
||||
db.Results.RemoveRange(linkedResults);
|
||||
}
|
||||
|
||||
db.Candidates.Remove(candidate);
|
||||
adminAuditService.AddEntry(
|
||||
session.TwitchUserId,
|
||||
@@ -213,11 +273,29 @@ public static partial class AdminSeasonManagementEndpoints
|
||||
"candidate",
|
||||
candidate.Id.ToString(),
|
||||
$"Kandidat {candidate.DisplayName} wurde gelöscht.",
|
||||
new { candidate.CategoryId, candidate.Platform },
|
||||
new
|
||||
{
|
||||
candidate.CategoryId,
|
||||
candidate.Platform,
|
||||
deletedNominations = linkedNominations.Count,
|
||||
deletedClips = linkedClips.Count,
|
||||
deletedVoteEntries = linkedVoteEntries.Count,
|
||||
deletedResults = linkedResults.Count,
|
||||
},
|
||||
RequestMetadataReader.Read(context));
|
||||
|
||||
await db.SaveChangesAsync(context.RequestAborted);
|
||||
return Results.Ok(new { deleted = true, candidateId });
|
||||
try
|
||||
{
|
||||
await db.SaveChangesAsync(context.RequestAborted);
|
||||
return Results.Ok(new { deleted = true, candidateId });
|
||||
}
|
||||
catch (DbUpdateException)
|
||||
{
|
||||
return Results.BadRequest(new
|
||||
{
|
||||
message = "Kandidat konnte nicht gelöscht werden, weil noch verknüpfte Daten blockieren.",
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private static string NormalizeCandidateChoice(string? value, string fallback, IReadOnlyCollection<string> allowedValues)
|
||||
|
||||
Reference in New Issue
Block a user