33 lines
1.6 KiB
C#
33 lines
1.6 KiB
C#
using DeepDrftModels.DTOs;
|
|
using DeepDrftModels.Enums;
|
|
|
|
namespace DeepDrftPublic.Client.Common;
|
|
|
|
/// <summary>
|
|
/// The single source of truth for a release's dedicated detail route (Phase 11 §2). A release
|
|
/// resolves to its per-medium detail page from its <see cref="ReleaseDto.EntryKey"/> and
|
|
/// <see cref="ReleaseMedium"/> — no round-trip needed at call sites that already hold the medium
|
|
/// (Archive cards, AlbumsView cards, the player-bar title). The thin <c>/tracks/{entryKey}</c>
|
|
/// redirect page fetches by EntryKey to discover the medium, then resolves through this same
|
|
/// helper, so the medium→route table lives in exactly one place.
|
|
/// </summary>
|
|
public static class ReleaseRoutes
|
|
{
|
|
/// <summary>
|
|
/// The dedicated detail route for a release: <c>/cuts/{entryKey}</c>, <c>/sessions/{entryKey}</c>,
|
|
/// or <c>/mixes/{entryKey}</c>. The route carries the release's opaque public EntryKey (Phase 11
|
|
/// §3e) — never the transparent int PK. Cut is the default arm so a new medium without an entry
|
|
/// here surfaces a build-visible gap rather than a silent fallthrough — extend the switch when a
|
|
/// fourth medium lands.
|
|
/// </summary>
|
|
public static string DetailHref(string entryKey, ReleaseMedium medium) => medium switch
|
|
{
|
|
ReleaseMedium.Session => $"/sessions/{entryKey}",
|
|
ReleaseMedium.Mix => $"/mixes/{entryKey}",
|
|
_ => $"/cuts/{entryKey}",
|
|
};
|
|
|
|
/// <summary>Convenience overload for call sites holding a <see cref="ReleaseDto"/>.</summary>
|
|
public static string DetailHref(ReleaseDto release) => DetailHref(release.EntryKey, release.Medium);
|
|
}
|