books/backend/Books.Api/Domain/Attachments/Events/AttachmentEvents.cs

81 lines
2.3 KiB
C#
Raw Normal View History

using EventFlow.Aggregates;
namespace Books.Api.Domain.Attachments.Events;
/// <summary>
/// Event raised when an attachment (bilag) is uploaded.
/// Required by Bogføringsloven § 6 for document retention.
/// </summary>
public class AttachmentUploadedEvent(
string companyId,
string fileName,
string originalFileName,
string contentType,
long fileSize,
string storagePath,
string uploadedBy,
string? draftId = null,
string? transactionId = null) : AggregateEvent<AttachmentAggregate, AttachmentId>
{
public string CompanyId { get; } = companyId;
/// <summary>
/// Stored filename (sanitized/unique).
/// </summary>
public string FileName { get; } = fileName;
/// <summary>
/// Original filename as uploaded by user.
/// </summary>
public string OriginalFileName { get; } = originalFileName;
/// <summary>
/// MIME type (e.g., application/pdf, image/png).
/// </summary>
public string ContentType { get; } = contentType;
/// <summary>
/// File size in bytes.
/// </summary>
public long FileSize { get; } = fileSize;
/// <summary>
/// Path to the stored file (local path or blob URL).
/// </summary>
public string StoragePath { get; } = storagePath;
public string UploadedBy { get; } = uploadedBy;
/// <summary>
/// Optional reference to journal entry draft.
/// </summary>
public string? DraftId { get; } = draftId;
/// <summary>
/// Optional reference to posted transaction.
/// </summary>
public string? TransactionId { get; } = transactionId;
}
/// <summary>
/// Event raised when an attachment is linked to a transaction after posting.
/// </summary>
public class AttachmentLinkedToTransactionEvent(
string transactionId) : AggregateEvent<AttachmentAggregate, AttachmentId>
{
public string TransactionId { get; } = transactionId;
}
/// <summary>
/// Event raised when an attachment is deleted.
/// Note: Per Bogføringsloven § 6, attachments should be retained for 5 years.
/// This event is for administrative cleanup only.
/// </summary>
public class AttachmentDeletedEvent(
string deletedBy,
string reason) : AggregateEvent<AttachmentAggregate, AttachmentId>
{
public string DeletedBy { get; } = deletedBy;
public string Reason { get; } = reason;
}