public TenantInitializer( IAdminTenantConfiguration adminTenantConfiguration, ITenantsRepository tenantsRepository, IMediator mediator, IGuid guid, IMapper mapper, ILogger <TenantInitializer> logger) { _adminTenantConfiguration = adminTenantConfiguration; _tenantsRepository = tenantsRepository; _mediator = mediator; _guid = guid; _mapper = mapper; _logger = logger; }
private async Task <RequestResult <UserDto> > CreateUser( IAdminTenantConfiguration config, Tenant tenant, Guid correlationId) { var userContext = new RequestContext() .WithTenantContext(new TenantContext(tenant.Id, tenant.Code, true)); var createUserCommand = new RegisterUserWithCredentialsCommand( _guid.GetGuid(), config.Email, config.UserDisplayName, config.Password) .WithCorrelationId(correlationId) .WithRequestContext(userContext); var createUserResult = await _mediator.Send(createUserCommand); if (!createUserResult.IsSuccess) { throw new DomainException(createUserResult); } return(createUserResult); }
private async Task <Guid> CreateTenant(IAdminTenantConfiguration config, RequestContext requestContext) { var createTenantCommand = new CreateTenantCommand( config.TenantName, config.TenantCode, config.AllowedOrigin, config.TokenSecret, config.TokenExpirationInMinutes, true, false, false, config.DefaultLanguage, true) .WithRequestContext(requestContext); var createTenantResult = await _mediator.Send(createTenantCommand); if (!createTenantResult.IsSuccess) { throw new DomainException(createTenantResult); } return(createTenantCommand.CorrelationId); }