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