Fix W3-T4 review: log+sanitize catch messages, add validation attrs to CmsTrackUpdateRequest, document T3 delete dependency

This commit is contained in:
Daniel Harvey
2026-05-18 15:43:00 -04:00
parent 531115b655
commit 7b20694a31
3 changed files with 13 additions and 6 deletions
+7 -2
View File
@@ -1,4 +1,5 @@
@page "/cms/tracks/{Id:int}"
@* InteractiveServer: page injects ITrackService in-process; ITokenService reads localStorage via JS interop over the circuit. *@
@rendermode InteractiveServer
@using AuthBlocksWeb.HierarchicalAuthorize
@using AuthBlocksWeb.Services
@@ -12,6 +13,7 @@
@inject ISnackbar Snackbar
@inject IDialogService DialogService
@inject NavigationManager Nav
@inject ILogger<TrackEdit> Logger
<PageTitle>Edit Track — DeepDrft CMS</PageTitle>
@@ -154,7 +156,8 @@
}
catch (Exception ex)
{
Snackbar.Add($"Save failed: {ex.Message}", Severity.Error);
Logger.LogError(ex, "Save failed for track {TrackId}", Id);
Snackbar.Add("Save failed — please try again.", Severity.Error);
}
finally
{
@@ -162,6 +165,7 @@
}
}
// DELETE api/cms/track/{Id} is handled by CmsDeleteController (T3 branch).
private async Task ConfirmDelete()
{
if (_track is null) return;
@@ -194,7 +198,8 @@
}
catch (Exception ex)
{
Snackbar.Add($"Delete failed: {ex.Message}", Severity.Error);
Logger.LogError(ex, "Delete failed for track {TrackId}", Id);
Snackbar.Add("Delete failed — please try again.", Severity.Error);
_busy = false;
}
}
+1
View File
@@ -5,6 +5,7 @@
@using Microsoft.AspNetCore.Components.Web
@using Microsoft.AspNetCore.Components.Web.Virtualization
@using static Microsoft.AspNetCore.Components.Web.RenderMode
@using Microsoft.Extensions.Logging
@using Microsoft.JSInterop
@using DeepDrftCms
@using DeepDrftModels.Entities
+5 -4
View File
@@ -1,3 +1,4 @@
using System.ComponentModel.DataAnnotations;
using DeepDrftModels.Entities;
using DeepDrftWeb.Services;
using Microsoft.AspNetCore.Authorization;
@@ -51,8 +52,8 @@ public class CmsEditController : ControllerBase
}
public record CmsTrackUpdateRequest(
string TrackName,
string Artist,
string? Album,
string? Genre,
[Required, MaxLength(200)] string TrackName,
[Required, MaxLength(200)] string Artist,
[MaxLength(200)] string? Album,
[MaxLength(100)] string? Genre,
DateOnly? ReleaseDate);