コード例 #1
0
        /// <summary>
        /// Initializes any collection properties after deserialization, like next requests for paging.
        /// </summary>
        /// <param name="accessPackageAssignmentToInitialize">The <see cref="AccessPackageAssignment"/> with the collection properties to initialize.</param>
        private void InitializeCollectionProperties(AccessPackageAssignment accessPackageAssignmentToInitialize)
        {
            if (accessPackageAssignmentToInitialize != null && accessPackageAssignmentToInitialize.AdditionalData != null)
            {
                if (accessPackageAssignmentToInitialize.AccessPackageAssignmentRequests != null && accessPackageAssignmentToInitialize.AccessPackageAssignmentRequests.CurrentPage != null)
                {
                    accessPackageAssignmentToInitialize.AccessPackageAssignmentRequests.AdditionalData = accessPackageAssignmentToInitialize.AdditionalData;

                    object nextPageLink;
                    accessPackageAssignmentToInitialize.AdditionalData.TryGetValue("*****@*****.**", out nextPageLink);
                    var nextPageLinkString = nextPageLink as string;

                    if (!string.IsNullOrEmpty(nextPageLinkString))
                    {
                        accessPackageAssignmentToInitialize.AccessPackageAssignmentRequests.InitializeNextPageRequest(
                            this.Client,
                            nextPageLinkString);
                    }
                }

                if (accessPackageAssignmentToInitialize.AccessPackageAssignmentResourceRoles != null && accessPackageAssignmentToInitialize.AccessPackageAssignmentResourceRoles.CurrentPage != null)
                {
                    accessPackageAssignmentToInitialize.AccessPackageAssignmentResourceRoles.AdditionalData = accessPackageAssignmentToInitialize.AdditionalData;

                    object nextPageLink;
                    accessPackageAssignmentToInitialize.AdditionalData.TryGetValue("*****@*****.**", out nextPageLink);
                    var nextPageLinkString = nextPageLink as string;

                    if (!string.IsNullOrEmpty(nextPageLinkString))
                    {
                        accessPackageAssignmentToInitialize.AccessPackageAssignmentResourceRoles.InitializeNextPageRequest(
                            this.Client,
                            nextPageLinkString);
                    }
                }
            }
        }
コード例 #2
0
 /// <summary>
 /// Adds the specified AccessPackageAssignment to the collection via POST.
 /// </summary>
 /// <param name="accessPackageAssignment">The AccessPackageAssignment to add.</param>
 /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
 /// <returns>The created AccessPackageAssignment.</returns>
 public System.Threading.Tasks.Task <AccessPackageAssignment> AddAsync(AccessPackageAssignment accessPackageAssignment, CancellationToken cancellationToken)
 {
     this.ContentType = "application/json";
     this.Method      = "POST";
     return(this.SendAsync <AccessPackageAssignment>(accessPackageAssignment, cancellationToken));
 }
コード例 #3
0
 /// <summary>
 /// Adds the specified AccessPackageAssignment to the collection via POST.
 /// </summary>
 /// <param name="accessPackageAssignment">The AccessPackageAssignment to add.</param>
 /// <returns>The created AccessPackageAssignment.</returns>
 public System.Threading.Tasks.Task <AccessPackageAssignment> AddAsync(AccessPackageAssignment accessPackageAssignment)
 {
     return(this.AddAsync(accessPackageAssignment, CancellationToken.None));
 }
コード例 #4
0
        /// <summary>
        /// Creates the specified AccessPackageAssignment using POST.
        /// </summary>
        /// <param name="accessPackageAssignmentToCreate">The AccessPackageAssignment to create.</param>
        /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
        /// <returns>The created AccessPackageAssignment.</returns>
        public async System.Threading.Tasks.Task <AccessPackageAssignment> CreateAsync(AccessPackageAssignment accessPackageAssignmentToCreate, CancellationToken cancellationToken)
        {
            this.ContentType = "application/json";
            this.Method      = "POST";
            var newEntity = await this.SendAsync <AccessPackageAssignment>(accessPackageAssignmentToCreate, cancellationToken).ConfigureAwait(false);

            this.InitializeCollectionProperties(newEntity);
            return(newEntity);
        }
コード例 #5
0
 /// <summary>
 /// Creates the specified AccessPackageAssignment using POST.
 /// </summary>
 /// <param name="accessPackageAssignmentToCreate">The AccessPackageAssignment to create.</param>
 /// <returns>The created AccessPackageAssignment.</returns>
 public System.Threading.Tasks.Task <AccessPackageAssignment> CreateAsync(AccessPackageAssignment accessPackageAssignmentToCreate)
 {
     return(this.CreateAsync(accessPackageAssignmentToCreate, CancellationToken.None));
 }
コード例 #6
0
        /// <summary>
        /// Updates the specified AccessPackageAssignment using PATCH.
        /// </summary>
        /// <param name="accessPackageAssignmentToUpdate">The AccessPackageAssignment to update.</param>
        /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
        /// <exception cref="ClientException">Thrown when an object returned in a response is used for updating an object in Microsoft Graph.</exception>
        /// <returns>The updated AccessPackageAssignment.</returns>
        public async System.Threading.Tasks.Task <AccessPackageAssignment> UpdateAsync(AccessPackageAssignment accessPackageAssignmentToUpdate, CancellationToken cancellationToken)
        {
            if (accessPackageAssignmentToUpdate.AdditionalData != null)
            {
                if (accessPackageAssignmentToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.ResponseHeaders) ||
                    accessPackageAssignmentToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.StatusCode))
                {
                    throw new ClientException(
                              new Error
                    {
                        Code    = GeneratedErrorConstants.Codes.NotAllowed,
                        Message = String.Format(GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, accessPackageAssignmentToUpdate.GetType().Name)
                    });
                }
            }
            if (accessPackageAssignmentToUpdate.AdditionalData != null)
            {
                if (accessPackageAssignmentToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.ResponseHeaders) ||
                    accessPackageAssignmentToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.StatusCode))
                {
                    throw new ClientException(
                              new Error
                    {
                        Code    = GeneratedErrorConstants.Codes.NotAllowed,
                        Message = String.Format(GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, accessPackageAssignmentToUpdate.GetType().Name)
                    });
                }
            }
            this.ContentType = "application/json";
            this.Method      = "PATCH";
            var updatedEntity = await this.SendAsync <AccessPackageAssignment>(accessPackageAssignmentToUpdate, cancellationToken).ConfigureAwait(false);

            this.InitializeCollectionProperties(updatedEntity);
            return(updatedEntity);
        }