books/backend/Books.Api/Commands/Attachments/AttachmentCommands.cs

59 lines
1.8 KiB
C#
Raw Normal View History

using Books.Api.Domain.Attachments;
using EventFlow.Commands;
namespace Books.Api.Commands.Attachments;
/// <summary>
/// Command to upload an attachment (bilag).
/// Required by Bogføringsloven § 6 for document retention.
/// </summary>
public class UploadAttachmentCommand(
AttachmentId aggregateId,
string companyId,
string fileName,
string originalFileName,
string contentType,
long fileSize,
string storagePath,
string uploadedBy,
string? draftId = null,
string? transactionId = null)
: Command<AttachmentAggregate, AttachmentId>(aggregateId)
{
public string CompanyId { get; } = companyId;
public string FileName { get; } = fileName;
public string OriginalFileName { get; } = originalFileName;
public string ContentType { get; } = contentType;
public long FileSize { get; } = fileSize;
public string StoragePath { get; } = storagePath;
public string UploadedBy { get; } = uploadedBy;
public string? DraftId { get; } = draftId;
public string? TransactionId { get; } = transactionId;
}
/// <summary>
/// Command to link an attachment to a posted transaction.
/// </summary>
public class LinkAttachmentToTransactionCommand(
AttachmentId aggregateId,
string transactionId)
: Command<AttachmentAggregate, AttachmentId>(aggregateId)
{
public string TransactionId { get; } = transactionId;
}
/// <summary>
/// Command to delete an attachment.
/// Note: Per Bogføringsloven § 6, this should only be used after
/// the 5-year retention period.
/// </summary>
public class DeleteAttachmentCommand(
AttachmentId aggregateId,
string deletedBy,
string reason)
: Command<AttachmentAggregate, AttachmentId>(aggregateId)
{
public string DeletedBy { get; } = deletedBy;
public string Reason { get; } = reason;
}