Ability to remove archive Dungeons
This commit is contained in:
@@ -238,6 +238,7 @@
|
||||
<th class="text-left py-2">Last Activity</th>
|
||||
<th class="text-left py-2">Persisted</th>
|
||||
<th class="text-left py-2">Boss</th>
|
||||
<th class="text-left py-2">Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="text-gray-300">
|
||||
@@ -245,13 +246,22 @@
|
||||
{
|
||||
<tr class="border-t border-gray-800">
|
||||
<td class="py-2 font-mono">@dungeon.Id.ToString()[..8]...</td>
|
||||
<td class="py-2">T@dungeon.Tier</td>
|
||||
<td class="py-2">@($"T{dungeon.Tier}")</td>
|
||||
<td class="py-2">@dungeon.LevelBracketMin-@dungeon.LevelBracketMax</td>
|
||||
<td class="py-2">@dungeon.CreatorName</td>
|
||||
<td class="py-2">@dungeon.CreatedAt.ToString("u")</td>
|
||||
<td class="py-2">@dungeon.LastActivity.ToString("u")</td>
|
||||
<td class="py-2">@(dungeon.PersistedAt?.ToString("u") ?? "-")</td>
|
||||
<td class="py-2">@(dungeon.BossKilled ? "Yes" : "No")</td>
|
||||
<td class="py-2">
|
||||
<form method="post" asp-page-handler="DeleteArchive" onsubmit="return confirm('Delete this archived dungeon? This cannot be undone.')">
|
||||
@Html.AntiForgeryToken()
|
||||
<input type="hidden" name="id" value="@dungeon.Id" />
|
||||
<button type="submit" class="btn btn-sm btn-danger">
|
||||
Delete
|
||||
</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
|
||||
@@ -150,6 +150,22 @@ public class IndexModel : AdminPageModel
|
||||
|
||||
return RedirectToPage();
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnPostDeleteArchiveAsync(Guid id)
|
||||
{
|
||||
var existing = await _db.Set<DungeonPersistence>().FindAsync(id);
|
||||
if (existing == null)
|
||||
{
|
||||
TempData["Error"] = "Archived dungeon not found.";
|
||||
return RedirectToPage();
|
||||
}
|
||||
|
||||
_db.Set<DungeonPersistence>().Remove(existing);
|
||||
await _db.SaveChangesAsync();
|
||||
TempData["Message"] = "Archived dungeon deleted successfully.";
|
||||
|
||||
return RedirectToPage();
|
||||
}
|
||||
|
||||
private static string FormatDuration(TimeSpan duration)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user