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

Add EventId property to EventBase #987

Merged
merged 1 commit into from
Dec 14, 2023
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ public abstract record EventBase
{
public static JsonSerializerOptions JsonSerializerOptions { get; } = new();

public required Guid EventId { get; init; }
public required DateTime CreatedUtc { get; init; }
public required Guid SourceUserId { get; init; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public async Task Execute(Guid eytsAwardedEmailsJobId, Guid personId)

_dbContext.AddEvent(new EytsAwardedEmailSentEvent
{
EventId = Guid.NewGuid(),
EytsAwardedEmailsJobId = eytsAwardedEmailsJobId,
PersonId = personId,
EmailAddress = item.EmailAddress,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public async Task Execute(Guid inductionCompletedEmailsJobId, Guid personId)

_dbContext.AddEvent(new InductionCompletedEmailSentEvent
{
EventId = Guid.NewGuid(),
InductionCompletedEmailsJobId = inductionCompletedEmailsJobId,
PersonId = personId,
EmailAddress = item.EmailAddress,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public async Task Execute(Guid internationalQtsAwardedEmailsJobId, Guid personId

_dbContext.AddEvent(new InternationalQtsAwardedEmailSentEvent
{
EventId = Guid.NewGuid(),
InternationalQtsAwardedEmailsJobId = internationalQtsAwardedEmailsJobId,
PersonId = personId,
EmailAddress = item.EmailAddress,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public async Task Execute(Guid qtsAwardedEmailsJobId, Guid personId)

_dbContext.AddEvent(new QtsAwardedEmailSentEvent
{
EventId = Guid.NewGuid(),
QtsAwardedEmailsJobId = qtsAwardedEmailsJobId,
PersonId = personId,
EmailAddress = item.EmailAddress,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ public async Task<IActionResult> OnPost()

_dbContext.AddEvent(new UserAddedEvent()
{
EventId = Guid.NewGuid(),
User = Core.Events.User.FromModel(newUser),
SourceUserId = User.GetUserId(),
CreatedUtc = _clock.UtcNow
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ public async Task<IActionResult> OnPost()

_dbContext.AddEvent(new UserUpdatedEvent
{
EventId = Guid.NewGuid(),
User = Core.Events.User.FromModel(user),
SourceUserId = User.GetUserId(),
CreatedUtc = _clock.UtcNow,
Expand All @@ -128,6 +129,7 @@ public async Task<IActionResult> OnPostDeactivate()

_dbContext.AddEvent(new UserDeactivatedEvent
{
EventId = Guid.NewGuid(),
User = Core.Events.User.FromModel(user),
SourceUserId = User.GetUserId(),
CreatedUtc = _clock.UtcNow
Expand All @@ -152,6 +154,7 @@ public async Task<IActionResult> OnPostActivate()

_dbContext.AddEvent(new UserActivatedEvent
{
EventId = Guid.NewGuid(),
User = Core.Events.User.FromModel(user),
SourceUserId = User.GetUserId(),
CreatedUtc = _clock.UtcNow
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public void EventSerializesCorrectly()
// Arrange
var @e = new UserActivatedEvent()
{
EventId = Guid.NewGuid(),
CreatedUtc = DateTime.UtcNow,
SourceUserId = DataStore.Postgres.Models.User.SystemUserId,
User = new()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ public async Task PublishEvents_EventObserverThrows_DoesNotThrow()

private EventBase CreateDummyEvent() => new DummyEvent()
{
EventId = Guid.NewGuid(),
DummyProperty = Faker.Name.FullName(),
CreatedUtc = TestableClock.Initial.ToUniversalTime(),
SourceUserId = DataStore.Postgres.Models.User.SystemUserId
Expand Down
Loading