namespace Books.Api.EventFlow.ReadModels;

/// <summary>
/// DTO for attachment (bilag) read model.
/// </summary>
public class AttachmentReadModelDto
{
    public required string Id { get; init; }
    public required string CompanyId { get; init; }
    public required string FileName { get; init; }
    public required string OriginalFileName { get; init; }
    public required string ContentType { get; init; }
    public required long FileSize { get; init; }
    public required string StoragePath { get; init; }
    public required string UploadedBy { get; init; }
    public required DateTimeOffset UploadedAt { get; init; }
    public string? DraftId { get; init; }
    public string? TransactionId { get; init; }
    public required DateTimeOffset RetentionEndDate { get; init; }
    public required bool IsDeleted { get; init; }

    public static AttachmentReadModelDto FromReadModel(AttachmentReadModel model) => new()
    {
        Id = model.AggregateId,
        CompanyId = model.CompanyId,
        FileName = model.FileName,
        OriginalFileName = model.OriginalFileName,
        ContentType = model.ContentType,
        FileSize = model.FileSize,
        StoragePath = model.StoragePath,
        UploadedBy = model.UploadedBy,
        UploadedAt = model.UploadedAt,
        DraftId = model.DraftId,
        TransactionId = model.TransactionId,
        RetentionEndDate = model.RetentionEndDate,
        IsDeleted = model.IsDeleted
    };
}
