コード例 #1
0
        /// <summary>
        /// Updates the specified UsageRight using PATCH.
        /// </summary>
        /// <param name="usageRightToUpdate">The UsageRight 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 UsageRight.</returns>
        public async System.Threading.Tasks.Task <UsageRight> UpdateAsync(UsageRight usageRightToUpdate, CancellationToken cancellationToken)
        {
            if (usageRightToUpdate.AdditionalData != null)
            {
                if (usageRightToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.ResponseHeaders) ||
                    usageRightToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.StatusCode))
                {
                    throw new ClientException(
                              new Error
                    {
                        Code    = GeneratedErrorConstants.Codes.NotAllowed,
                        Message = String.Format(GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, usageRightToUpdate.GetType().Name)
                    });
                }
            }
            if (usageRightToUpdate.AdditionalData != null)
            {
                if (usageRightToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.ResponseHeaders) ||
                    usageRightToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.StatusCode))
                {
                    throw new ClientException(
                              new Error
                    {
                        Code    = GeneratedErrorConstants.Codes.NotAllowed,
                        Message = String.Format(GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, usageRightToUpdate.GetType().Name)
                    });
                }
            }
            this.ContentType = "application/json";
            this.Method      = "PATCH";
            var updatedEntity = await this.SendAsync <UsageRight>(usageRightToUpdate, cancellationToken).ConfigureAwait(false);

            this.InitializeCollectionProperties(updatedEntity);
            return(updatedEntity);
        }
コード例 #2
0
        /// <summary>
        /// Creates the specified UsageRight using POST.
        /// </summary>
        /// <param name="usageRightToCreate">The UsageRight to create.</param>
        /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
        /// <returns>The created UsageRight.</returns>
        public async System.Threading.Tasks.Task <UsageRight> CreateAsync(UsageRight usageRightToCreate, CancellationToken cancellationToken)
        {
            this.ContentType = "application/json";
            this.Method      = "POST";
            var newEntity = await this.SendAsync <UsageRight>(usageRightToCreate, cancellationToken).ConfigureAwait(false);

            this.InitializeCollectionProperties(newEntity);
            return(newEntity);
        }
コード例 #3
0
 /// <summary>
 /// Creates the specified UsageRight using POST.
 /// </summary>
 /// <param name="usageRightToCreate">The UsageRight to create.</param>
 /// <returns>The created UsageRight.</returns>
 public System.Threading.Tasks.Task <UsageRight> CreateAsync(UsageRight usageRightToCreate)
 {
     return(this.CreateAsync(usageRightToCreate, CancellationToken.None));
 }
コード例 #4
0
 /// <summary>
 /// Initializes any collection properties after deserialization, like next requests for paging.
 /// </summary>
 /// <param name="usageRightToInitialize">The <see cref="UsageRight"/> with the collection properties to initialize.</param>
 private void InitializeCollectionProperties(UsageRight usageRightToInitialize)
 {
 }
コード例 #5
0
 /// <summary>
 /// Adds the specified UsageRight to the collection via POST.
 /// </summary>
 /// <param name="usageRight">The UsageRight to add.</param>
 /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
 /// <returns>The created UsageRight.</returns>
 public System.Threading.Tasks.Task <UsageRight> AddAsync(UsageRight usageRight, CancellationToken cancellationToken)
 {
     this.ContentType = "application/json";
     this.Method      = "POST";
     return(this.SendAsync <UsageRight>(usageRight, cancellationToken));
 }
コード例 #6
0
 /// <summary>
 /// Adds the specified UsageRight to the collection via POST.
 /// </summary>
 /// <param name="usageRight">The UsageRight to add.</param>
 /// <returns>The created UsageRight.</returns>
 public System.Threading.Tasks.Task <UsageRight> AddAsync(UsageRight usageRight)
 {
     return(this.AddAsync(usageRight, CancellationToken.None));
 }