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