public async Task HandleAsync(AccountDeleted @event) { await _handler .Run(async() => { if (@event.Soft) { var user = await _userRepository.GetByIdAsync(@event.UserId); user.Value.State = "deleted"; await _userRepository.EditAsync(user.Value); await _stateService.SetAsync(@event.UserId, user.Value.State); return; } await _cache.DeleteAsync(@event.UserId); await _stateService.SetAsync(@event.UserId, "deleted"); await _userRepository.DeleteAsync(@event.UserId); }) .OnError((ex, logger) => { logger.Error(ex, $"Error occured while handling {@event.GetType().Name} event"); }) .ExecuteAsync(); }