Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added missing aggregateId in events #67

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
branches: [ "main" ]

env:
PACKAGE_VERSION: 0.2.0
PACKAGE_VERSION: 0.2.1

jobs:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@

namespace ToDoList.Domain.Events.TaskLists;

public record TaskCompletedStatusUpdpated(Guid TaskListId, Guid TaskId, bool IsCompleted) : Event;
public record TaskCompletedStatusUpdpated(
Guid TaskListId,
Guid Id,
bool IsCompleted)
: Event(Id);
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ namespace ToDoList.Domain.Events.TaskLists;
public record TaskListNameUpdated(
Guid Id,
string NewName
) : Event;
) : Event(Id);
2 changes: 1 addition & 1 deletion Demos/ToDoList.Domain/Events/TaskLists/TaskTitleUpdated.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ public record TaskTitleUpdated(
Guid? TaskListId,
Guid Id,
string NewTitle
) : Event;
) : Event(Id);
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace ToDoList.Domain.Events.UserAccounts;

public record UserAccountEmailAddressChanged(
Guid Id,
Guid UserAccountId,
string NewEmail
) : Event;
) : Event(Id);
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
namespace ToDoList.Domain.Events.UserAccounts;

public record UserAccountEmailAddressConfirmed(
Guid Id,
Guid UserAccountId
) : Event;
) : Event(Id);
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace ToDoList.Domain.Events.UserAccounts;

public record UserAccountEmailAssigned(
Guid Id,
Guid UserAccountId,
string EmailAddress
) : Event;
) : Event(Id);
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
using CloudFabric.EventSourcing.EventStore;
using ToDoList.Domain.Utilities.Extensions;

namespace ToDoList.Domain.Events.UserAccounts;

public record UserAccountEmailRegistered(
string EmailAddress
) : Event;
) : Event(EmailAddress.HashGuid());
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@

namespace ToDoList.Domain.Events.UserAccounts;

public record UserAccountPasswordUpdated(string NewHashedPassword) : Event;
public record UserAccountPasswordUpdated(
Guid Id,
string NewHashedPassword
) : Event(Id);
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ public record UserAccountRegistered(
Guid Id,
string FirstName,
string HashedPassword
) : Event;
) : Event(Id);
2 changes: 1 addition & 1 deletion Demos/ToDoList.Domain/UserAccount.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public UserAccount(Guid id, string firstName, string hashedPassword)

public void UpdatePassword(string newHashedPassword)
{
Apply(new UserAccountPasswordUpdated(newHashedPassword));
Apply(new UserAccountPasswordUpdated(Id, newHashedPassword));
}

#region Event Handlers
Expand Down
8 changes: 4 additions & 4 deletions Demos/ToDoList.Domain/UserAccountEmailAddress.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,17 @@ public UserAccountEmailAddress(string emailAddress) : base()
}
public void ChangeEmailAddress(string newEmail)
{
Apply(new UserAccountEmailAddressChanged(UserAccountId, newEmail));
Apply(new UserAccountEmailAddressChanged(Id, UserAccountId, newEmail));
}

public void ConfirmEmailAddress()
{
Apply(new UserAccountEmailAddressConfirmed(UserAccountId));
Apply(new UserAccountEmailAddressConfirmed(Id, UserAccountId));
}

public void AssignUserAccount(Guid userAccountId)
{
Apply(new UserAccountEmailAssigned(userAccountId, EmailAddress));
Apply(new UserAccountEmailAssigned(Id, userAccountId, EmailAddress));
}

#region Event Handlers
Expand All @@ -53,7 +53,7 @@ public void On(UserAccountEmailRegistered @event)

public void On(UserAccountEmailAssigned @event)
{
UserAccountId = @event.AggregateId;
UserAccountId = @event.UserAccountId;
}

public void On(UserAccountEmailAddressChanged @event)
Expand Down
18 changes: 18 additions & 0 deletions Demos/ToDoList.Domain/Utilities/Extensions/StringExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using System.Text;

namespace ToDoList.Domain.Utilities.Extensions;

public static class StringExtensions
{
public static Guid HashGuid(this string str)
{
// Super fast non-cryptographic hash function:
// https://cyan4973.github.io/xxHash/
// 128 version is used because that's what Guid uses for it's value
var hash = new System.IO.Hashing.XxHash128();

hash.Append(Encoding.UTF8.GetBytes(str));

return new Guid(hash.GetCurrentHash());
}
}