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

Commit

Permalink
fix: fire CreatedEvent/DeletedEvent for
Browse files Browse the repository at this point in the history
UpdateChannelEnvironmentVariablesCommand

Signed-off-by: Matthew Fisher <[email protected]>
  • Loading branch information
bacongobbler committed Jun 13, 2022
1 parent a5a62b1 commit fe229ec
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 fe229ec

Please sign in to comment.