예제 #1
0
        public async Task Handle(RemoveSuperheroCommand notification, CancellationToken cancellationToken)
        {
            if (!notification.IsValid())
            {
                NotifyValidationErrors(notification);
                return;
            }

            _superheroRepository.Remove(notification.Id);

            if (await CommitAsync())
            {
                var superheroEvent = new SuperheroRemovedEvent(notification.Id);
                await _bus.RaiseEvent(superheroEvent);

                await _auditEventService.Subscribe(new AuditEvent(
                                                       Guid.NewGuid(),
                                                       nameof(Superhero),
                                                       notification.Id,
                                                       notification.Username,
                                                       AuditEventAction.Remove
                                                       ));
            }
        }