Skip to content

Commit

Permalink
Added string ID item events. (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
mgernand authored Dec 13, 2021
1 parent 9e7deee commit 689372a
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 1 deletion.
17 changes: 17 additions & 0 deletions src/Fluxera.Entity/DomainEvents/ItemAdded.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,21 @@ public ItemAdded(TAggregateRoot item)

public TAggregateRoot Item { get; }
}

/// <summary>
/// A domain event that indicates that a new item of <see cref="AggregateRoot{TAggregateRoot}"/>
/// has been added to the data storage. This event uses a <see cref="string"/> for the ID type.
/// </summary>
/// <typeparam name="TAggregateRoot">The aggregate root type.</typeparam>
[PublicAPI]
public sealed class ItemAdded<TAggregateRoot> : IDomainEvent
where TAggregateRoot : AggregateRoot<TAggregateRoot>
{
public ItemAdded(TAggregateRoot item)
{
this.Item = item;
}

public TAggregateRoot Item { get; }
}
}
20 changes: 20 additions & 0 deletions src/Fluxera.Entity/DomainEvents/ItemRemoved.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,24 @@ public ItemRemoved(TAggregateRoot item, string id)

public string ID { get; }
}

/// <summary>
/// A domain event that indicates that a new item of <see cref="AggregateRoot{TAggregateRoot}"/>
/// has been removed to the data storage. This event uses a <see cref="string"/> for the ID type.
/// </summary>
/// <typeparam name="TAggregateRoot">The aggregate root type.</typeparam>
[PublicAPI]
public sealed class ItemRemoved<TAggregateRoot> : IDomainEvent
where TAggregateRoot : AggregateRoot<TAggregateRoot>
{
public ItemRemoved(TAggregateRoot item, string id)
{
this.Item = item;
this.ID = id;
}

public TAggregateRoot Item { get; }

public string ID { get; }
}
}
17 changes: 17 additions & 0 deletions src/Fluxera.Entity/DomainEvents/ItemUpdated.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,21 @@ public ItemUpdated(TAggregateRoot item)

public TAggregateRoot Item { get; }
}

/// <summary>
/// A domain event that indicates that a new item of <see cref="AggregateRoot{TAggregateRoot}"/>
/// has been updated in the data storage. This event uses a <see cref="string"/> for the ID type.
/// </summary>
/// <typeparam name="TAggregateRoot">The aggregate root type.</typeparam>
[PublicAPI]
public sealed class ItemUpdated<TAggregateRoot> : IDomainEvent
where TAggregateRoot : AggregateRoot<TAggregateRoot>
{
public ItemUpdated(TAggregateRoot item)
{
this.Item = item;
}

public TAggregateRoot Item { get; }
}
}
2 changes: 1 addition & 1 deletion src/Fluxera.Entity/Entity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
/// <typeparam name="TEntity">The entity type.</typeparam>
[PublicAPI]
public abstract class Entity<TEntity> : Entity<TEntity, string>
where TEntity : Entity<TEntity, string>
where TEntity : Entity<TEntity>
{
[Ignore]
public override bool IsTransient => string.IsNullOrWhiteSpace(this.ID);
Expand Down

0 comments on commit 689372a

Please sign in to comment.