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

            return(updatedEntity);
        }
 /// <summary>
 /// Adds the specified ManagementCondition to the collection via POST.
 /// </summary>
 /// <param name="managementCondition">The ManagementCondition to add.</param>
 /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
 /// <returns>The created ManagementCondition.</returns>
 public System.Threading.Tasks.Task <ManagementCondition> AddAsync(ManagementCondition managementCondition, CancellationToken cancellationToken)
 {
     this.ContentType = "application/json";
     this.Method      = "POST";
     managementCondition.ODataType = string.Concat("#", StringHelper.ConvertTypeToLowerCamelCase(managementCondition.GetType().FullName));
     return(this.SendAsync <ManagementCondition>(managementCondition, cancellationToken));
 }