From e9f43e738bf2637ff9e161c48ce97377bb811498 Mon Sep 17 00:00:00 2001 From: StuartFerguson Date: Mon, 8 Jun 2026 14:58:22 +0100 Subject: [PATCH] Refactor domain events to use record types Rewrote ImportLogCreatedEvent and FileAddedToImportLogEvent as concise C# record types with positional parameters. Moved both to a new FileImportLogAggregateDomainEvents.cs file, consolidating and simplifying their definitions. Removed the original class files. --- .../FileAddedToImportLogEvent.cs | 121 ------------------ .../FileImportLogAggregateDomainEvents.cs | 9 ++ .../ImportLogCreatedEvent.cs | 40 ------ 3 files changed, 9 insertions(+), 161 deletions(-) delete mode 100644 FileProcessor.FileImportLog.DomainEvents/FileAddedToImportLogEvent.cs create mode 100644 FileProcessor.FileImportLog.DomainEvents/FileImportLogAggregateDomainEvents.cs delete mode 100644 FileProcessor.FileImportLog.DomainEvents/ImportLogCreatedEvent.cs diff --git a/FileProcessor.FileImportLog.DomainEvents/FileAddedToImportLogEvent.cs b/FileProcessor.FileImportLog.DomainEvents/FileAddedToImportLogEvent.cs deleted file mode 100644 index 5ae776c..0000000 --- a/FileProcessor.FileImportLog.DomainEvents/FileAddedToImportLogEvent.cs +++ /dev/null @@ -1,121 +0,0 @@ -namespace FileProcessor.FileImportLog.DomainEvents -{ - using System; - using Shared.DomainDrivenDesign.EventSourcing; - - public record FileAddedToImportLogEvent : DomainEvent - { - #region Constructors - - /// - /// Initializes a new instance of the class. - /// - /// The aggregate identifier. - /// The file identifier. - /// The estate identifier. - /// The merchant identifier. - /// The user identifier. - /// The file profile identifier. - /// Name of the original file. - /// The file path. - /// The file uploaded date time. - public FileAddedToImportLogEvent(Guid aggregateId, - Guid fileId, - Guid estateId, - Guid merchantId, - Guid userId, - Guid fileProfileId, - String originalFileName, - String filePath, - DateTime fileUploadedDateTime) : base(aggregateId, Guid.NewGuid()) - { - this.FileImportLogId = aggregateId; - this.FileId = fileId; - this.EstateId = estateId; - this.MerchantId = merchantId; - this.UserId = userId; - this.FileProfileId = fileProfileId; - this.OriginalFileName = originalFileName; - this.FilePath = filePath; - this.FileUploadedDateTime = fileUploadedDateTime; - } - - #endregion - - #region Properties - - /// - /// Gets or sets the estate identifier. - /// - /// - /// The estate identifier. - /// - public Guid EstateId { get; init; } - - /// - /// Gets or sets the file identifier. - /// - /// - /// The file identifier. - /// - public Guid FileId { get; init; } - - /// - /// Gets or sets the file import log identifier. - /// - /// - /// The file import log identifier. - /// - public Guid FileImportLogId { get; init; } - - /// - /// Gets or sets the file path. - /// - /// - /// The file path. - /// - public String FilePath { get; init; } - - /// - /// Gets or sets the file profile identifier. - /// - /// - /// The file profile identifier. - /// - public Guid FileProfileId { get; init; } - - /// - /// Gets or sets the file uploaded date time. - /// - /// - /// The file uploaded date time. - /// - public DateTime FileUploadedDateTime { get; init; } - - /// - /// Gets or sets the merchant identifier. - /// - /// - /// The merchant identifier. - /// - public Guid MerchantId { get; init; } - - /// - /// Gets or sets the name of the original file. - /// - /// - /// The name of the original file. - /// - public String OriginalFileName { get; init; } - - /// - /// Gets or sets the user identifier. - /// - /// - /// The user identifier. - /// - public Guid UserId { get; init; } - - #endregion - } -} \ No newline at end of file diff --git a/FileProcessor.FileImportLog.DomainEvents/FileImportLogAggregateDomainEvents.cs b/FileProcessor.FileImportLog.DomainEvents/FileImportLogAggregateDomainEvents.cs new file mode 100644 index 0000000..e103107 --- /dev/null +++ b/FileProcessor.FileImportLog.DomainEvents/FileImportLogAggregateDomainEvents.cs @@ -0,0 +1,9 @@ +using System; + +namespace FileProcessor.FileImportLog.DomainEvents +{ + using Shared.DomainDrivenDesign.EventSourcing; + + public record ImportLogCreatedEvent(Guid FileImportLogId, Guid EstateId, DateTime ImportLogDateTime) : DomainEvent(FileImportLogId, Guid.NewGuid()); + public record FileAddedToImportLogEvent(Guid FileImportLogId, Guid FileId, Guid EstateId, Guid MerchantId, Guid UserId, Guid FileProfileId, String OriginalFileName, String FilePath, DateTime FileUploadedDateTime) : DomainEvent(FileImportLogId, Guid.NewGuid()); +} diff --git a/FileProcessor.FileImportLog.DomainEvents/ImportLogCreatedEvent.cs b/FileProcessor.FileImportLog.DomainEvents/ImportLogCreatedEvent.cs deleted file mode 100644 index 5e7761f..0000000 --- a/FileProcessor.FileImportLog.DomainEvents/ImportLogCreatedEvent.cs +++ /dev/null @@ -1,40 +0,0 @@ -using System; - -namespace FileProcessor.FileImportLog.DomainEvents -{ - using Shared.DomainDrivenDesign.EventSourcing; - - public record ImportLogCreatedEvent : DomainEvent - { - public ImportLogCreatedEvent(Guid aggregateId, Guid estateId, DateTime importLogDateTime) : base(aggregateId, Guid.NewGuid()) - { - this.EstateId = estateId; - this.ImportLogDateTime = importLogDateTime; - this.FileImportLogId = aggregateId; - } - - /// - /// Gets or sets the estate identifier. - /// - /// - /// The estate identifier. - /// - public Guid EstateId { get; init; } - - /// - /// Gets or sets the file import log identifier. - /// - /// - /// The file import log identifier. - /// - public Guid FileImportLogId { get; init; } - - /// - /// Gets or sets the import log date time. - /// - /// - /// The import log date time. - /// - public DateTime ImportLogDateTime { get; init; } - } -}