From fe229ec6b32bbffc5acd456ced1901015dac36a7 Mon Sep 17 00:00:00 2001 From: Matthew Fisher Date: Mon, 13 Jun 2022 12:46:41 -0700 Subject: [PATCH] fix: fire CreatedEvent/DeletedEvent for UpdateChannelEnvironmentVariablesCommand Signed-off-by: Matthew Fisher --- .../UpdateChannelEnvironmentVariablesCommand.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Application/EnvironmentVariables/Commands/UpdateChannelEnvironmentVariablesCommand.cs b/src/Application/EnvironmentVariables/Commands/UpdateChannelEnvironmentVariablesCommand.cs index b3198d68b..e2f083e41 100644 --- a/src/Application/EnvironmentVariables/Commands/UpdateChannelEnvironmentVariablesCommand.cs +++ b/src/Application/EnvironmentVariables/Commands/UpdateChannelEnvironmentVariablesCommand.cs @@ -36,6 +36,11 @@ public async Task Handle(UpdateChannelEnvironmentVariablesCommand request, var envVariablesToBeUpdated = EnvironmentVariablesToBeUpdated(existingVariables, request.EnvironmentVariables); var envVariablesToBeDeleted = EnvironmentVariablesToBeRemoved(existingVariables, request.EnvironmentVariables); + foreach (var entity in envVariablesToBeAdded) + { + entity.AddDomainEvent(new CreatedEvent(entity)); + } + _context.EnvironmentVariables.AddRange(envVariablesToBeAdded); if (existingVariables.Count > 0) @@ -55,6 +60,11 @@ public async Task Handle(UpdateChannelEnvironmentVariablesCommand request, } } + foreach (var entity in envVariablesToBeDeleted) + { + entity.AddDomainEvent(new DeletedEvent(entity)); + } + _context.EnvironmentVariables.RemoveRange(envVariablesToBeDeleted); await _context.SaveChangesAsync(cancellationToken);