Base solution for your next web application
Ends in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

Unique Tenant Setting #4496


User avatar
0
BobIngham created

I have added my own setting provider with a tenant scope and added it to the preinitialize method of my module. I set these settings in

TenantRegistrationAppService.RegisterTenant

and I can modify them by adding a tab to

tenant.settings.component.html

and adding code to

TenantSettingsAppService.UpdateAllSettings

So far so good. One of these settings is a voucher code which must be unique as it will be used by an app to register with the system and the voucher code will find the tenant using unique voucher code setting. How do search for all settings given a unique name (App.NuageTenantManagement.VoucherCode) to ensure a modified value is unique and how do I find a tenant from the same unique voucher code setting?


6 Answer(s)
  • User Avatar
    0
    aaron created
    Support Team

    Inject IRepository<Setting, long> and do as you would for any other entity.

  • User Avatar
    0
    BobIngham created

    Doh!!!! Thanks, Aaron.

  • User Avatar
    0
    BobIngham created

    Hmmm, the problem, Aaron, is that settingsRepository only return those settings for the current tenant, how do I read settings for all tenants to ensure the value is unique?

  • User Avatar
    0
    aaron created
    Support Team

    You can DisableFilter for IMayHaveTenant:

    using (_unitOfWorkManager.Current.DisableFilter(AbpDataFilters.MayHaveTenant))
    {
        var settings = _settingRepository.GetAllList();                
    }
    

    Read the documentation on Data Filters.

  • User Avatar
    0
    BobIngham created

    Thanks, Aaron, that did the trick. Sorry about the niaivety, I am still in the learning -phase.

  • User Avatar
    0
    aaron created
    Support Team

    It's fine. You'll get the hang of it in time to come!