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

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

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