Hi,
I have created some settings for each tenant, that I wish to be autopopulated once a tenant is created.
How can I accomplish such functionality?
12 Answer(s)
-
0
Hi @Hercules
Are you willing to change the default values of settings for each Tenant ? If not, you can modify the default setting values.
If you want to insert different settings for each tenant, you need to do it in TenantManager's CreateWithAdminUserAsync method.
-
0
Thank you ismcagdas
Maybe I wasn't clear enough on my question.
I have created some settings i.e. Countries and I want each tenant to have full control over the Countries of their application.
I also want as soon as the Tenant is created, that I autopopulate a list of countries to start with, before the end user can perform CRUD operations on the Countries settings page.
How can I set a "signal" that as soon as tenant is created, it should autopopulate ot the the Countries Table linked with the Tenant's ID?
-
0
https://aspnetboilerplate.com/Pages/Documents/EventBus-Domain-Events
-
0
Hi again,
Since Tenant is already CRUDed by abp is there any event already implemented for this purpose when a tenant is created?
-
0
Yes, read the section on Entity Changes.
-
0
@Hercules
There is no such an event for Tenant creation, you need to trigger and handle it by yourself according to https://aspnetboilerplate.com/Pages/Documents/EventBus-Domain-Events as @aaron shared. It is very easy to implement.
-
0
Thank you for the answer.
Can we create the Event in the TenantAppService uder the followign method:
public async Task CreateTenant(CreateTenantInput input) {}
Or is there any better place to do it?
-
0
you can create a separate class to handle this.
Similar to UserFriendCacheSyncronizer in ANZ project
-
0
I have created the below Event Manager, which is calling a method that contains the seed data that I wish to autopopulate the tenant upon creation.
public TenantInitializerEventManager(ITenantInitializerService tenantInitializerService) { this.tenantInitializerService = tenantInitializerService; } public void HandleEvent(EntityCreatedEventData<Tenant> eventData) { this.tenantInitializerService.CreateNewTenantSeedData(eventData.Entity); }
This Event is not fired when a tenant is created, where do I declare to execute the Event?
-
0
Show the class definition.
-
0
public class TenantInitializerEventManager : IEventHandler<EntityCreatedEventData<Tenant>> { private readonly ITenantInitializerService tenantInitializerService;
public TenantInitializerEventManager(ITenantInitializerService tenantInitializerService) { this.tenantInitializerService = tenantInitializerService; } public void HandleEvent(EntityCreatedEventData<Tenant> eventData) { this.tenantInitializerService.CreateNewTenantSeedData(eventData.Entity); } }
-
0
Implement
ITransientDependency
.