示例#1
0
        public async Task HandleAsync(AccountDeletedIntegrationEvent integrationEvent, CancellationToken cancellationToken = default)
        {
            try
            {
                var user = await _userRepository.GetByIdAsync(integrationEvent.AccountId);

                user.AddDeletedEvent(integrationEvent.CorrelationId);
                await _communicationBus.DispatchDomainEventsAsync(user, cancellationToken);

                await _userRepository.DeleteAsync(user);

                var userDeletedIntegrationEvent = new UserDeletedIntegrationEvent(integrationEvent.CorrelationId, user.Id);
                await _integrationEventBus.PublishIntegrationEventAsync(userDeletedIntegrationEvent);
            }
            catch (Exception e)
            {
                _logger.LogIntegrationEventError(ServiceComponentEnumeration.RivaUsers, integrationEvent,
                                                 "userId={userId}, message={message}, stackTrace={stackTrace}", integrationEvent.AccountId,
                                                 e.Message, e.StackTrace);
                var userDeletionCompletedIntegrationEventFailure = new UserDeletionCompletedIntegrationEventFailure(
                    integrationEvent.CorrelationId, IntegrationEventErrorCodeEnumeration.UnexpectedError.DisplayName,
                    IntegrationEventErrorMessage.UnexpectedError, integrationEvent.AccountId);
                await _integrationEventBus.PublishIntegrationEventAsync(userDeletionCompletedIntegrationEventFailure);
            }
        }
示例#2
0
 protected void When(UserDeletedIntegrationEvent @event)
 {
     Id = @event.AggregateRootId;
 }
示例#3
0
 public void Delete(string email)
 {
     Raise(UserDeletedIntegrationEvent.Create(this));
 }