Exemplo n.º 1
0
        private static async Task <Permission> CreatePermissionAsync(string resourceLink, string userLink, PermissionMode mode, string resourcePartitionKey = null)
        {
            Permission permission = new Permission
            {
                Id             = Guid.NewGuid().ToString("N"),
                PermissionMode = mode,
                ResourceLink   = resourceLink
            };

            if (resourcePartitionKey != null)
            {
                permission.ResourcePartitionKey = new PartitionKey(resourcePartitionKey);
            }

            ResourceResponse <Permission> response = await DocumentClientHelper.ExecuteWithRetries <ResourceResponse <Permission> >(
                client,
                () => client.CreatePermissionAsync(userLink, permission));

            return(response.Resource);
        }