Base solution for your next web application
Open Closed

How to get an entity across tenants? #9095


User avatar
0
marble68 created

I'm working on a system where each tenant can setup an entity that represents an individual; these entities are unique across all tenants.

On the public site - I have an action where the unique ID of the individual is passed as the ID.

A unique URL is created for individuals that

Do I need to create a custom service to do this?


5 Answer(s)
  • User Avatar
    1
    maliming created
    Support Team

    hi

    If your host and tenant are using a database, you can query these entities by disabling the filter or switching to the host. If they use different databases.

    https://aspnetboilerplate.com/Pages/Documents/Data-Filters#disable-filters https://aspnetboilerplate.com/Pages/Documents/Multi-Tenancy#switching-between-host-and-tenants

  • User Avatar
    0
    marble68 created

    Ok - I've got this working - part way.

    Now, the Taker goes to the public website, enters some info - and I need to update that Taker entity from the public website.

    Does disabling filters resolve calling CreateOrEdit?

    Here's what I'm doing:

                using (var uow = UnitOfWorkManager.Begin())
                {
                    using (CurrentUnitOfWork.SetTenantId(null))
                    {
                        using (CurrentUnitOfWork.DisableFilter(AbpDataFilters.SoftDelete))
                        {
                            _takersAppService.CreateOrEdit(input).Wait();
    
                            uow.Complete();
                        }
                    }
                }
    

    The error I'm getting is:

    AbpAuthorizationException: Current user did not login to the application!

    THanks for any advice.

  • User Avatar
    0
    marble68 created

    It turns out I didn't have this working - the public website was getting the MVC cookie.

    I added a host entry for the public website so it's a different domain, and it now fails.

  • User Avatar
    0
    maliming created
    Support Team

    hi marble68

    AbpAuthorizationException: Current user did not login to the application!

    This is because the authentication issue has nothing to do with the code you shared.

    You don't need to disable the filter after you set up the tenantid of the unitofwork.

  • User Avatar
    0
    marble68 created

    Unit of work, clearing filters, etc. did the trick. that's how I do this when necessary now.

    Thank you.