/// <summary> /// Adds the specified PrintOperation to the collection via POST. /// </summary> /// <param name="printOperation">The PrintOperation to add.</param> /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param> /// <returns>The created PrintOperation.</returns> public System.Threading.Tasks.Task <PrintOperation> AddAsync(PrintOperation printOperation, CancellationToken cancellationToken) { this.ContentType = "application/json"; this.Method = "POST"; printOperation.ODataType = string.Concat("#", StringHelper.ConvertTypeToLowerCamelCase(printOperation.GetType().FullName)); return(this.SendAsync <PrintOperation>(printOperation, cancellationToken)); }
/// <summary> /// Updates the specified PrintOperation using PATCH. /// </summary> /// <param name="printOperationToUpdate">The PrintOperation 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 PrintOperation.</returns> public async System.Threading.Tasks.Task <PrintOperation> UpdateAsync(PrintOperation printOperationToUpdate, CancellationToken cancellationToken) { if (printOperationToUpdate.AdditionalData != null) { if (printOperationToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.ResponseHeaders) || printOperationToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.StatusCode)) { throw new ClientException( new Error { Code = GeneratedErrorConstants.Codes.NotAllowed, Message = String.Format(GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, printOperationToUpdate.GetType().Name) }); } } if (printOperationToUpdate.AdditionalData != null) { if (printOperationToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.ResponseHeaders) || printOperationToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.StatusCode)) { throw new ClientException( new Error { Code = GeneratedErrorConstants.Codes.NotAllowed, Message = String.Format(GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, printOperationToUpdate.GetType().Name) }); } } this.ContentType = "application/json"; this.Method = "PATCH"; var updatedEntity = await this.SendAsync <PrintOperation>(printOperationToUpdate, cancellationToken).ConfigureAwait(false); this.InitializeCollectionProperties(updatedEntity); return(updatedEntity); }