using System.ComponentModel.DataAnnotations; using System.Text.Json.Serialization; using API.Schema.ActionsContext.Actions; using API.Schema.ActionsContext.Actions.Generic; namespace API.Controllers.DTOs; public sealed record ActionRecord : Identifiable { public ActionRecord(Schema.ActionsContext.ActionRecord actionRecord) : base(actionRecord.Key) { Action = actionRecord.Action; PerformedAt = actionRecord.PerformedAt; MangaId = actionRecord is ActionWithMangaRecord m ? m.MangaId : null; ChapterId = actionRecord is ActionWithChapterRecord c ? c.ChapterId : null; } /// /// /// [Required] public ActionsEnum Action { get; init; } /// /// /// [Required] public DateTime PerformedAt { get; init; } /// /// MangaId if Record is /// [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] public string? MangaId { get; init; } /// /// ChapterId if Record is /// [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] public string? ChapterId { get; init; } }