Browse Source

Merge pull request #9497 from abpframework/enisn/rel-4.4/fix-tenant-created-event

tenant-management - Add event publishing for TenantCreatedEto
pull/9498/head
Halil İbrahim Kalkan 5 years ago
committed by GitHub
parent
commit
2ccf96cb7a
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 21
      modules/tenant-management/src/Volo.Abp.TenantManagement.Application/Volo/Abp/TenantManagement/TenantAppService.cs

21
modules/tenant-management/src/Volo.Abp.TenantManagement.Application/Volo/Abp/TenantManagement/TenantAppService.cs

@ -4,6 +4,8 @@ using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Dtos;
using Volo.Abp.Data; using Volo.Abp.Data;
using Volo.Abp.EventBus.Distributed;
using Volo.Abp.MultiTenancy;
using Volo.Abp.ObjectExtending; using Volo.Abp.ObjectExtending;
namespace Volo.Abp.TenantManagement namespace Volo.Abp.TenantManagement
@ -14,15 +16,18 @@ namespace Volo.Abp.TenantManagement
protected IDataSeeder DataSeeder { get; } protected IDataSeeder DataSeeder { get; }
protected ITenantRepository TenantRepository { get; } protected ITenantRepository TenantRepository { get; }
protected ITenantManager TenantManager { get; } protected ITenantManager TenantManager { get; }
protected IDistributedEventBus DistributedEventBus { get; }
public TenantAppService( public TenantAppService(
ITenantRepository tenantRepository, ITenantRepository tenantRepository,
ITenantManager tenantManager, ITenantManager tenantManager,
IDataSeeder dataSeeder) IDataSeeder dataSeeder,
IDistributedEventBus distributedEventBus)
{ {
DataSeeder = dataSeeder; DataSeeder = dataSeeder;
TenantRepository = tenantRepository; TenantRepository = tenantRepository;
TenantManager = tenantManager; TenantManager = tenantManager;
DistributedEventBus = distributedEventBus;
} }
public virtual async Task<TenantDto> GetAsync(Guid id) public virtual async Task<TenantDto> GetAsync(Guid id)
@ -63,10 +68,22 @@ namespace Volo.Abp.TenantManagement
await CurrentUnitOfWork.SaveChangesAsync(); 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)) using (CurrentTenant.Change(tenant.Id, tenant.Name))
{ {
//TODO: Handle database creation? //TODO: Handle database creation?
// TODO: Seeder might be triggered via event handler.
await DataSeeder.SeedAsync( await DataSeeder.SeedAsync(
new DataSeedContext(tenant.Id) new DataSeedContext(tenant.Id)
.WithProperty("AdminEmail", input.AdminEmailAddress) .WithProperty("AdminEmail", input.AdminEmailAddress)

Loading…
Cancel
Save