예제 #1
0
 /// <summary>
 /// Adds the specified SynchronizationTemplate to the collection via POST.
 /// </summary>
 /// <param name="synchronizationTemplate">The SynchronizationTemplate to add.</param>
 /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
 /// <returns>The created SynchronizationTemplate.</returns>
 public System.Threading.Tasks.Task <SynchronizationTemplate> AddAsync(SynchronizationTemplate synchronizationTemplate, CancellationToken cancellationToken)
 {
     this.ContentType = "application/json";
     this.Method      = "POST";
     return(this.SendAsync <SynchronizationTemplate>(synchronizationTemplate, cancellationToken));
 }
예제 #2
0
 /// <summary>
 /// Adds the specified SynchronizationTemplate to the collection via POST.
 /// </summary>
 /// <param name="synchronizationTemplate">The SynchronizationTemplate to add.</param>
 /// <returns>The created SynchronizationTemplate.</returns>
 public System.Threading.Tasks.Task <SynchronizationTemplate> AddAsync(SynchronizationTemplate synchronizationTemplate)
 {
     return(this.AddAsync(synchronizationTemplate, CancellationToken.None));
 }
 /// <summary>
 /// Initializes any collection properties after deserialization, like next requests for paging.
 /// </summary>
 /// <param name="synchronizationTemplateToInitialize">The <see cref="SynchronizationTemplate"/> with the collection properties to initialize.</param>
 private void InitializeCollectionProperties(SynchronizationTemplate synchronizationTemplateToInitialize)
 {
 }
        /// <summary>
        /// Creates the specified SynchronizationTemplate using POST.
        /// </summary>
        /// <param name="synchronizationTemplateToCreate">The SynchronizationTemplate to create.</param>
        /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
        /// <returns>The created SynchronizationTemplate.</returns>
        public async System.Threading.Tasks.Task <SynchronizationTemplate> CreateAsync(SynchronizationTemplate synchronizationTemplateToCreate, CancellationToken cancellationToken)
        {
            this.ContentType = "application/json";
            this.Method      = "POST";
            var newEntity = await this.SendAsync <SynchronizationTemplate>(synchronizationTemplateToCreate, cancellationToken).ConfigureAwait(false);

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

            this.InitializeCollectionProperties(updatedEntity);
            return(updatedEntity);
        }