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

Insert Organization Unit Id #2715


User avatar
0
velu created

How to insert Organization Unit id?

Please provide CRUD example for Organization Unit . I am not able achieve this.


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

    Hi,

    Are you getting an exception ? Because AspNet Zero already has a creating organization unit functionality. You can check OrganizationUnitAppService class for that.

  • User Avatar
    0
    velu created

    <cite>ismcagdas: </cite> Hi,

    Are you getting an exception ? Because AspNet Zero already has a creating organization unit functionality. You can check OrganizationUnitAppService class for that.

    Organization Unit menu is working properly.

    When i am creating Product master that time Organization Unit Id not able to store in database. That CRUD example required.

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    I think you are trying to integrate organization unit with your product entity, am I right ? Can you explain a bit more detailed what you are trying to do ?

    Thanks.

  • User Avatar
    0
    velu created

    <cite>ismcagdas: </cite> Hi,

    I think you are trying to integrate organization unit with your product entity, am I right ? Can you explain a bit more detailed what you are trying to do ?

    Thanks.

    Yes, I am trying to integrate organization unit with product entity. For this CRUD example required.

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Did you checked adding/removing users from organizaiton unit ? If you did and it was not helpful, please share the code you have written and we can ty to help.

    Thanks.

  • User Avatar
    0
    velu created

    <cite>ismcagdas: </cite> Hi,

    Did you checked adding/removing users from organizaiton unit ? If you did and it was not helpful, please share the code you have written and we can ty to help.

    Thanks.

    Yes, We have checked adding/removing users from organizaiton unit.

    I am trying to integrate organization unit with product entity. For this CRUD example required.

    Please help us its urgent.

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Have you read this document <a class="postlink" href="http://aspnetboilerplate.com/Pages/Documents/Zero/Organization-Units">http://aspnetboilerplate.com/Pages/Docu ... tion-Units</a> ? Especially this part explains exactly what you want <a class="postlink" href="http://aspnetboilerplate.com/Pages/Documents/Zero/Organization-Units#creating-entity-belongs-to-an-organization-unit">http://aspnetboilerplate.com/Pages/Docu ... ation-unit</a>

  • User Avatar
    0
    velu created

    <cite>ismcagdas: </cite> Hi,

    Have you read this document <a class="postlink" href="http://aspnetboilerplate.com/Pages/Documents/Zero/Organization-Units">http://aspnetboilerplate.com/Pages/Docu ... tion-Units</a> ? Especially this part explains exactly what you want <a class="postlink" href="http://aspnetboilerplate.com/Pages/Documents/Zero/Organization-Units#creating-entity-belongs-to-an-organization-unit">http://aspnetboilerplate.com/Pages/Docu ... ation-unit</a>

    In this URL example for fetching the data. I required insert and update Organization Unit Id in Product entity.

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    So, when creating/editing a product you will select an existing organiztion unit, right ?

  • User Avatar
    0
    velu created

    <cite>ismcagdas: </cite> Hi,

    So, when creating/editing a product you will select an existing organiztion unit, right ?

    Yes, Current Login Users organiztion unit..

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Thanks for the explanation, now I understand your case :). So, when inserting/updating a product you can get current user's organization unit id like this.

    long? orgUnitId = null;
    var userOrgUnit = _userOrganizationUnitRepository.GetAll().FirstOrDefault(e => e.TenantId == AbpSession.TenantId && e.UserId == AbpSession.UserId);
    if (userOrgUnit != null)
    {
        orgUnitId = userOrgUnit.OrganizationUnitId;
    }
    

    Then you can set your product's organizationUnitId to orgUnitId variable. But don't forget, in AspNet Zero a user can be in more than one organization unit, so in this case above code gets just one organization unit for current user.

    I don't know your domain but maybe you need to restrict adding a user more than one organization unit.