public async Task SeedAsync()
 {
     var policy = CreatePolicy(_logger, nameof(SeedAsync));
     await policy.ExecuteAsync(async() =>
     {
         if (!await _personQueries.UserNameOrEmailExists("userName", "*****@*****.**"))
         {
             var tasks = new[] { SeedJobPosting(), SeedPerson() };
             await Task.WhenAll(tasks);
         }
     });
 }
        public async Task <PersonDto> Handle(RegisterPersonCommand request, CancellationToken cancellationToken)
        {
            if (await _personQueries.UserNameOrEmailExists(request.UserName, request.EmailAddress))
            {
                throw new PersonnelDomainException(ErrorTypes.RegistrationError, new[] { "A user with this username or email address already exists" });
            }

            var person = new Person(request.UserName, request.EmailAddress, request.FirstName, request.LastName,
                                    _mapper.Map <Address>(request.HomeAddress),
                                    _mapper.Map <Address>(request.MailingAddress));

            _logger.LogInformation("----- Creating Person - UserName: {@UserName}", person.UserName);

            var result = _personRepository.Add(person);

            await _personRepository.UnitOfWork.SaveChangesAsync();

            _logger.LogInformation("----- Created Person - UserName: {@UserName}", person.UserName);

            _eventBus.Publish(new PersonRegisteredIntegrationEvent(result.Id, request.Password, result.UserName));

            return(_mapper.Map <PersonDto>(result));
        }