public virtual async Task <TenantDto> CreateAsync(TenantCreateDto input) { var tenant = await TenantManager.CreateAsync(input.Name); input.MapExtraPropertiesTo(tenant); await TenantRepository.InsertAsync(tenant); await CurrentUnitOfWork.SaveChangesAsync(); await DistributedEventBus.PublishAsync( new TenantCreatedEto { Id = tenant.Id, Name = tenant.Name, Properties = { { "AdminEmail", input.AdminEmailAddress }, { "AdminPassword", input.AdminPassword } } }); using (CurrentTenant.Change(tenant.Id, tenant.Name)) { //TODO: Handle database creation? // TODO: Seeder might be triggered via event handler. await DataSeeder.SeedAsync( new DataSeedContext(tenant.Id) .WithProperty("AdminEmail", input.AdminEmailAddress) .WithProperty("AdminPassword", input.AdminPassword) ); } return(ObjectMapper.Map <Tenant, TenantDto>(tenant)); }
public virtual async Task <TenantDto> CreateAsync(TenantCreateDto input) { var tenant = await TenantManager.CreateAsync(input.Name); input.MapExtraPropertiesTo(tenant); await TenantRepository.InsertAsync(tenant); await CurrentUnitOfWork.SaveChangesAsync(); using (CurrentTenant.Change(tenant.Id, tenant.Name)) { //TODO: Handle database creation? await DataSeeder.SeedAsync( new DataSeedContext(tenant.Id) .WithProperty("AdminEmail", input.AdminEmailAddress) .WithProperty("AdminPassword", input.AdminPassword) ); } return(ObjectMapper.Map <Tenant, TenantDto>(tenant)); }