Hi, I need to ensure that for some (IMustHaveTenant, IFullAudited) entities, when a specific Feature is granted, than a certain set of table rows (identified by natural key values) exists, i.e. is inserted if not existing or undeleted if soft deleted.
This logic must occours in both cases: when that Feaure is directly added to tenants and when an Edition including that Feature is applyed to tenants. Obviously the record set must be soft deleted when that Feature is removed from Tenant/Edition, Edition is deleted,...
Normally I would override some entity's Manager methods, concatenating base method logic with my custom one, in a [UnitOfWork] context, but here we have two different entities involved and I can't find a common base entry point to customize, so I'm asking:
- am I looking in the right direction to achieve my needs, or there is a better way to implement custom logic on Feature assignement?
- if I am right (customize at Domain Service level), which approach should I follow, event-based or non event-based? a. Hide/override TenantManager's HandleEvent* and implementing variousIEventHandler in EditionManager? b. Override TenantManager's SetFeatureValueAsync, UpdateAsync (for Edition change) and DeleteAsync, plus EditionManager's SetFeatureValuesAsync and DeleteAsync?
Thanks for any advice Cheers
You can use https://aspnetboilerplate.com/Pages/Documents/EventBus-Domain-Events to handle this situation.
There is an example in the AspNet Zero's source code. An event is triggered on https://github.com/aspnetzero/aspnet-zero-core/blob/dev/aspnet-core/src/MyCompanyName.AbpZeroTemplate.Application/MultiTenancy/TenantAppService.cs#L92 and handled in https://github.com/aspnetzero/aspnet-zero-core/blob/dev/aspnet-core/src/MyCompanyName.AbpZeroTemplate.Core/MultiTenancy/Payments/Stripe/StripeGatewayManager.cs#L284