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