Skip to content

Commit

Permalink
Fix Cashier issue
Browse files Browse the repository at this point in the history
  • Loading branch information
fredimachado committed May 14, 2024
1 parent 0abc89d commit 64a2176
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 11 deletions.
3 changes: 2 additions & 1 deletion src/Cashier/NCafe.Cashier.Api/Projections/ProductCreated.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

namespace NCafe.Cashier.Api.Projections;

public class ProductCreated : Event
public class ProductCreated : IEvent
{
public Guid Id { get; init; }
public string Name { get; init; }
public decimal Price { get; init; }
}
2 changes: 1 addition & 1 deletion src/Common/NCafe.Core/Domain/AggregateRoot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ internal void ClearPendingEvents()
_pendingEvents.Clear();
}

internal void ApplyEvent(IEvent @event)
internal void ApplyEvent(Event @event)
{
if (@event.Version != Version + 1)
{
Expand Down
8 changes: 8 additions & 0 deletions src/Common/NCafe.Core/Domain/Event.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace NCafe.Core.Domain;

public abstract class Event : IEvent
{
public Guid Id { get; protected set; }

public long Version { get; protected internal set; }
}
8 changes: 0 additions & 8 deletions src/Common/NCafe.Core/Domain/IEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,4 @@
public interface IEvent
{
Guid Id { get; }
long Version { get; }
}

public abstract class Event : IEvent
{
public Guid Id { get; protected set; }

public long Version { get; protected internal set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace NCafe.Core.Exceptions;

public class InvalidVersionException : DomainException
{
public InvalidVersionException(IEvent @event, AggregateRoot aggregateRoot)
public InvalidVersionException(Event @event, AggregateRoot aggregateRoot)
: base($"{@event.GetType().Name} Event v{@event.Version} cannot be applied to Aggregate {aggregateRoot.GetType().Name} : {aggregateRoot.Id} v{aggregateRoot.Version}")
{
}
Expand Down

0 comments on commit 64a2176

Please sign in to comment.