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

Extend User's UI and not User's Entity #3547


User avatar
0
bilalhaidar created

Hello, I am in need to extend Users Screen UI to allow an admin to select multiple values from a list. This would be translated as many-to-many in the database.

Can you give me guidelines on how to do so?

In other words, when a new user is created, I need to let the admin select multiple values (Regions) then in the DB I would have a new Table UserRegions or something where 1 Region can have more than 1 User and 1 User can belong to more than 1 Regions.

Thanks Bilal


10 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Adding a user to an organization unit is similar to what you are trying to do I think. You can check that, especially AbpUserOrganizationUnits table.

    Thanks.

  • User Avatar
    0
    bilalhaidar created

    Hi Ismail

    Can you illustrate more please?

    I have a concept of Regions and each region has one or more Camps.

    I want to assign users to either a Region or Camp (1 or more of each).

    Later I want a drop down list of users Regions and another drop down list to display camps filtered by Region.

    Also on an Entity called Beneficiary I need to add the Region or Camp as I need to retrieve later all beneficiaries that have the logged in user Region or Camp and list them in a page. In other words a logged in user has one or more regions and one or more camps. I want to show him beneficiaries only those belonging to his regions or camps.

    I appreciate your feedback

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @bilalhaidar,

    This is actually related to your domain rather than AspNet Zero :).

    But basically, you can define an entity named UserRegions(UserId, RegionId, TenantId). In that way, a user can be in more than one region and a region can contain more than one user. You can apply same approach for your other use cases.

    Thanks.

  • User Avatar
    0
    bilalhaidar created

    True. But you mentioned I can use OU so I'm explaining what I'm after and seeking your assistance to know if OU can help in this scenario.

    Do you think I can use OU given my requirements?

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @bilalhaidar,

    Ok, there is a misunderstanding I think :).

    I just wanted to say, there is the same data structure for User and Organization Unit relation. You can check same data structure (AbpUsers -> AbpUserOrganizationUnits -> AbpOrganizationUnits) and you can create a similar one for your entities.

    You will not relate your entities with OUs, at least I didn't suggest that :).

    Thanks.

  • User Avatar
    0
    bilalhaidar created

    Oh okay, I got that now :) You are saying that what I am trying to do as a relation between entities already exists between Users and OU.

    By the way, I found out I could use OUs :) The relation is hierarchical Region has camps (OU with sub OUs) :) Do you think I can build the solution based on OUs?

    I will teach the admin of the app, whenever a new Region to be added, to create a New OU and then all camps under it, to be created as OUs under it.

    I even went one step further, on one of the forms, I have 2 dropdown lists. The first would bring in all OUs under Regions OU to display in a dropdown. The second dropdown list is a cascading dropdown list based on the OU selected I get direct children of that OU to be camps.

    On the entity I would save either the Region OU ID in case camp is not selected otherwise, I save Camp OU ID.

    Then later, based on what OUs a user is assigned I query all Entities under the OUs that are assigned to the user together with their children OUs.

    I posted about that in a separate Thread and was asking how to do the same query in LINQ TO SQL.

    Thanks

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @bilalhaidar,

    Using OUs here might save you a lot of time instead of developing it with your custom entities. But I suggest you to think about it very carefully, because you know your domain better than us :).

    Thanks.

  • User Avatar
    0
    bilalhaidar created

    Thanks :)

    For OUs can I get an OU by name? I mean can I deal with it like any other entity?

    I would need to locate OUs by name for example I would put all regions under one Region called Regions. Then in code I want to get OUs under OU Regions. Doable?

  • User Avatar
    0
    ismcagdas created
    Support Team

    Yes, you can get an OU by it's name using IRepository<OrganizationUnit, long>. Just add an index to display name field so your query will execute faster.

    Thanks.

  • User Avatar
    0
    bilalhaidar created

    Thanks