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

            this.InitializeCollectionProperties(updatedEntity);
            return(updatedEntity);
        }
        /// <summary>
        /// Creates the specified ItemAttachment using POST.
        /// </summary>
        /// <param name="itemAttachmentToCreate">The ItemAttachment to create.</param>
        /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
        /// <returns>The created ItemAttachment.</returns>
        public async System.Threading.Tasks.Task <ItemAttachment> CreateAsync(ItemAttachment itemAttachmentToCreate, CancellationToken cancellationToken)
        {
            this.ContentType = "application/json";
            this.Method      = "POST";
            var newEntity = await this.SendAsync <ItemAttachment>(itemAttachmentToCreate, cancellationToken).ConfigureAwait(false);

            this.InitializeCollectionProperties(newEntity);
            return(newEntity);
        }
Beispiel #3
0
        /// <summary>
        /// Updates the specified ItemAttachment using PATCH.
        /// </summary>
        /// <param name="itemAttachmentToUpdate">The ItemAttachment to update.</param>
        /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
        /// <returns>The updated ItemAttachment.</returns>
        public async Task <ItemAttachment> UpdateAsync(ItemAttachment itemAttachmentToUpdate, CancellationToken cancellationToken)
        {
            this.ContentType = "application/json";
            this.Method      = "PATCH";
            var updatedEntity = await this.SendAsync <ItemAttachment>(itemAttachmentToUpdate, cancellationToken).ConfigureAwait(false);

            this.InitializeCollectionProperties(updatedEntity);
            return(updatedEntity);
        }
 /// <summary>
 /// Creates the specified ItemAttachment using POST.
 /// </summary>
 /// <param name="itemAttachmentToCreate">The ItemAttachment to create.</param>
 /// <returns>The created ItemAttachment.</returns>
 public System.Threading.Tasks.Task <ItemAttachment> CreateAsync(ItemAttachment itemAttachmentToCreate)
 {
     return(this.CreateAsync(itemAttachmentToCreate, CancellationToken.None));
 }
 /// <summary>
 /// Initializes any collection properties after deserialization, like next requests for paging.
 /// </summary>
 /// <param name="itemAttachmentToInitialize">The <see cref="ItemAttachment"/> with the collection properties to initialize.</param>
 private void InitializeCollectionProperties(ItemAttachment itemAttachmentToInitialize)
 {
 }
Beispiel #6
0
 /// <summary>
 /// Updates the specified ItemAttachment using PATCH.
 /// </summary>
 /// <param name="itemAttachmentToUpdate">The ItemAttachment to update.</param>
 /// <returns>The updated ItemAttachment.</returns>
 public Task <ItemAttachment> UpdateAsync(ItemAttachment itemAttachmentToUpdate)
 {
     return(this.UpdateAsync(itemAttachmentToUpdate, CancellationToken.None));
 }