From 689372a0d96e9b91fa84277a17c4785e74f8eba6 Mon Sep 17 00:00:00 2001 From: Matthias Gernand Date: Mon, 13 Dec 2021 04:03:09 +0100 Subject: [PATCH] Added string ID item events. (#5) --- src/Fluxera.Entity/DomainEvents/ItemAdded.cs | 17 ++++++++++++++++ .../DomainEvents/ItemRemoved.cs | 20 +++++++++++++++++++ .../DomainEvents/ItemUpdated.cs | 17 ++++++++++++++++ src/Fluxera.Entity/Entity.cs | 2 +- 4 files changed, 55 insertions(+), 1 deletion(-) diff --git a/src/Fluxera.Entity/DomainEvents/ItemAdded.cs b/src/Fluxera.Entity/DomainEvents/ItemAdded.cs index 0442b5f..d2b2dc8 100644 --- a/src/Fluxera.Entity/DomainEvents/ItemAdded.cs +++ b/src/Fluxera.Entity/DomainEvents/ItemAdded.cs @@ -19,4 +19,21 @@ public ItemAdded(TAggregateRoot item) public TAggregateRoot Item { get; } } + + /// + /// A domain event that indicates that a new item of + /// has been added to the data storage. This event uses a for the ID type. + /// + /// The aggregate root type. + [PublicAPI] + public sealed class ItemAdded : IDomainEvent + where TAggregateRoot : AggregateRoot + { + public ItemAdded(TAggregateRoot item) + { + this.Item = item; + } + + public TAggregateRoot Item { get; } + } } diff --git a/src/Fluxera.Entity/DomainEvents/ItemRemoved.cs b/src/Fluxera.Entity/DomainEvents/ItemRemoved.cs index afc1468..dfd16c0 100644 --- a/src/Fluxera.Entity/DomainEvents/ItemRemoved.cs +++ b/src/Fluxera.Entity/DomainEvents/ItemRemoved.cs @@ -22,4 +22,24 @@ public ItemRemoved(TAggregateRoot item, string id) public string ID { get; } } + + /// + /// A domain event that indicates that a new item of + /// has been removed to the data storage. This event uses a for the ID type. + /// + /// The aggregate root type. + [PublicAPI] + public sealed class ItemRemoved : IDomainEvent + where TAggregateRoot : AggregateRoot + { + public ItemRemoved(TAggregateRoot item, string id) + { + this.Item = item; + this.ID = id; + } + + public TAggregateRoot Item { get; } + + public string ID { get; } + } } diff --git a/src/Fluxera.Entity/DomainEvents/ItemUpdated.cs b/src/Fluxera.Entity/DomainEvents/ItemUpdated.cs index ba66032..b608690 100644 --- a/src/Fluxera.Entity/DomainEvents/ItemUpdated.cs +++ b/src/Fluxera.Entity/DomainEvents/ItemUpdated.cs @@ -19,4 +19,21 @@ public ItemUpdated(TAggregateRoot item) public TAggregateRoot Item { get; } } + + /// + /// A domain event that indicates that a new item of + /// has been updated in the data storage. This event uses a for the ID type. + /// + /// The aggregate root type. + [PublicAPI] + public sealed class ItemUpdated : IDomainEvent + where TAggregateRoot : AggregateRoot + { + public ItemUpdated(TAggregateRoot item) + { + this.Item = item; + } + + public TAggregateRoot Item { get; } + } } diff --git a/src/Fluxera.Entity/Entity.cs b/src/Fluxera.Entity/Entity.cs index acd3842..ff9a196 100644 --- a/src/Fluxera.Entity/Entity.cs +++ b/src/Fluxera.Entity/Entity.cs @@ -15,7 +15,7 @@ /// The entity type. [PublicAPI] public abstract class Entity : Entity - where TEntity : Entity + where TEntity : Entity { [Ignore] public override bool IsTransient => string.IsNullOrWhiteSpace(this.ID);