feat: normalize release-cardinal fields out of track into a Release entity (Phase 8 §8.0)

This commit is contained in:
daniel-c-harvey
2026-06-11 12:51:21 -04:00
parent 16f356a760
commit f767d288c5
33 changed files with 1032 additions and 297 deletions
+39 -16
View File
@@ -9,9 +9,40 @@ namespace DeepDrftData;
/// The DTO side mirrors the entity field-for-field; the audit columns
/// (CreatedAt, UpdatedAt) come from BaseEntity / BaseModel.
/// IsDeleted does not round-trip — soft-deleted rows are not exposed via the model.
///
/// Post Phase 8 §8.0: TrackEntity carries only track-cardinal fields plus a nullable
/// ReleaseId/Release. The release-cardinal data converts through the Release maps below.
/// </summary>
public class TrackConverter : IEntityToModelConverter<TrackEntity, TrackDto>
{
public static ReleaseDto Convert(ReleaseEntity entity) => new()
{
Id = entity.Id,
CreatedAt = entity.CreatedAt,
UpdatedAt = entity.UpdatedAt,
Title = entity.Title,
Artist = entity.Artist,
Genre = entity.Genre,
ReleaseDate = entity.ReleaseDate,
ImagePath = entity.ImagePath,
ReleaseType = entity.ReleaseType,
CreatedByUserId = entity.CreatedByUserId
};
public static ReleaseEntity Convert(ReleaseDto dto) => new()
{
Id = dto.Id,
CreatedAt = dto.CreatedAt,
UpdatedAt = dto.UpdatedAt,
Title = dto.Title,
Artist = dto.Artist,
Genre = dto.Genre,
ReleaseDate = dto.ReleaseDate,
ImagePath = dto.ImagePath,
ReleaseType = dto.ReleaseType,
CreatedByUserId = dto.CreatedByUserId
};
public static TrackDto Convert(TrackEntity entity) => new()
{
Id = entity.Id,
@@ -19,17 +50,15 @@ public class TrackConverter : IEntityToModelConverter<TrackEntity, TrackDto>
UpdatedAt = entity.UpdatedAt,
EntryKey = entity.EntryKey,
TrackName = entity.TrackName,
Artist = entity.Artist,
Album = entity.Album,
Genre = entity.Genre,
ReleaseDate = entity.ReleaseDate,
ImagePath = entity.ImagePath,
CreatedByUserId = entity.CreatedByUserId,
OriginalFileName = entity.OriginalFileName,
ReleaseType = entity.ReleaseType,
TrackNumber = entity.TrackNumber
TrackNumber = entity.TrackNumber,
ReleaseId = entity.ReleaseId,
Release = entity.Release is null ? null : Convert(entity.Release)
};
// DTO → entity maps track-cardinal fields + ReleaseId only. The Release navigation is left
// unset: the manager resolves/attaches the release row against the tracked context so a detached
// graph never overwrites a shared release record.
public static TrackEntity Convert(TrackDto model) => new()
{
Id = model.Id,
@@ -37,14 +66,8 @@ public class TrackConverter : IEntityToModelConverter<TrackEntity, TrackDto>
UpdatedAt = model.UpdatedAt,
EntryKey = model.EntryKey,
TrackName = model.TrackName,
Artist = model.Artist,
Album = model.Album,
Genre = model.Genre,
ReleaseDate = model.ReleaseDate,
ImagePath = model.ImagePath,
CreatedByUserId = model.CreatedByUserId,
OriginalFileName = model.OriginalFileName,
ReleaseType = model.ReleaseType,
TrackNumber = model.TrackNumber
TrackNumber = model.TrackNumber,
ReleaseId = model.ReleaseId
};
}