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

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