Skip to content
This repository has been archived by the owner on Oct 28, 2024. It is now read-only.

Commit

Permalink
Merge pull request #877 from bacongobbler/envvar-update-domain-events
Browse files Browse the repository at this point in the history
fix: fire CreatedEvent/DeletedEvent for
  • Loading branch information
bacongobbler authored Jun 13, 2022
2 parents 256054e + fe229ec commit ddc1f85
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ public async Task<Unit> Handle(UpdateChannelEnvironmentVariablesCommand request,
var envVariablesToBeUpdated = EnvironmentVariablesToBeUpdated(existingVariables, request.EnvironmentVariables);
var envVariablesToBeDeleted = EnvironmentVariablesToBeRemoved(existingVariables, request.EnvironmentVariables);

foreach (var entity in envVariablesToBeAdded)
{
entity.AddDomainEvent(new CreatedEvent<EnvironmentVariable>(entity));
}

_context.EnvironmentVariables.AddRange(envVariablesToBeAdded);

if (existingVariables.Count > 0)
Expand All @@ -55,6 +60,11 @@ public async Task<Unit> Handle(UpdateChannelEnvironmentVariablesCommand request,
}
}

foreach (var entity in envVariablesToBeDeleted)
{
entity.AddDomainEvent(new DeletedEvent<EnvironmentVariable>(entity));
}

_context.EnvironmentVariables.RemoveRange(envVariablesToBeDeleted);

await _context.SaveChangesAsync(cancellationToken);
Expand Down

0 comments on commit ddc1f85

Please sign in to comment.