Ejemplo n.º 1
0
        public async Task AddUserTypeToLocation(string buyerLocationID, HSUserType hsUserType, string accessToken, IOrderCloudClient oc)
        {
            // if we're seeding then use the passed in oc client
            // to support multiple environments and ease of setup for new orgs
            // else used the configured client
            var token    = oc == null ? null : accessToken;
            var ocClient = oc ?? _oc;

            var buyerID     = buyerLocationID.Split('-').First();
            var userGroupID = $"{buyerLocationID}-{hsUserType.UserGroupIDSuffix}";
            await ocClient.UserGroups.CreateAsync(buyerID, new PartialUserGroup()
            {
                ID   = userGroupID,
                Name = hsUserType.UserGroupName,
                xp   = new
                {
                    Role     = hsUserType.UserGroupIDSuffix.ToString(),
                    Type     = hsUserType.UserGroupType,
                    Location = buyerLocationID
                }
            }, token);

            foreach (var customRole in hsUserType.CustomRoles)
            {
                await ocClient.SecurityProfiles.SaveAssignmentAsync(new SecurityProfileAssignment()
                {
                    BuyerID           = buyerID,
                    UserGroupID       = userGroupID,
                    SecurityProfileID = customRole.ToString()
                }, token);
            }
        }
Ejemplo n.º 2
0
        public async Task AddUserTypeToLocation(string token, string buyerLocationID, HSUserType hsUserType)
        {
            var buyerID     = buyerLocationID.Split('-').First();
            var userGroupID = $"{buyerLocationID}-{hsUserType.UserGroupIDSuffix}";
            await _oc.UserGroups.CreateAsync(buyerID, new PartialUserGroup()
            {
                ID   = userGroupID,
                Name = hsUserType.UserGroupName,
                xp   = new
                {
                    Role     = hsUserType.UserGroupIDSuffix.ToString(),
                    Type     = hsUserType.UserGroupType,
                    Location = buyerLocationID
                }
            }, token);

            foreach (var customRole in hsUserType.CustomRoles)
            {
                await _oc.SecurityProfiles.SaveAssignmentAsync(new SecurityProfileAssignment()
                {
                    BuyerID           = buyerID,
                    UserGroupID       = userGroupID,
                    SecurityProfileID = customRole.ToString()
                }, token);
            }
        }
Ejemplo n.º 3
0
 public async Task AddUserTypeToLocation(string buyerLocationID, HSUserType hsUserType)
 {
     // not being called by seed endpoint - use stored ordercloud client and stored admin token
     await AddUserTypeToLocation(buyerLocationID, hsUserType, null, _oc);
 }