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

            this.InitializeCollectionProperties(newEntity);
            return(newEntity);
        }
        /// <summary>
        /// Updates the specified NoncustodialDataSource using PATCH.
        /// </summary>
        /// <param name="noncustodialDataSourceToUpdate">The NoncustodialDataSource to update.</param>
        /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
        /// <exception cref="Microsoft.Graph.ClientException">Thrown when an object returned in a response is used for updating an object in Microsoft Graph.</exception>
        /// <returns>The updated NoncustodialDataSource.</returns>
        public async System.Threading.Tasks.Task <NoncustodialDataSource> UpdateAsync(NoncustodialDataSource noncustodialDataSourceToUpdate, CancellationToken cancellationToken)
        {
            if (noncustodialDataSourceToUpdate.AdditionalData != null)
            {
                if (noncustodialDataSourceToUpdate.AdditionalData.ContainsKey(Microsoft.Graph.Constants.HttpPropertyNames.ResponseHeaders) ||
                    noncustodialDataSourceToUpdate.AdditionalData.ContainsKey(Microsoft.Graph.Constants.HttpPropertyNames.StatusCode))
                {
                    throw new Microsoft.Graph.ClientException(
                              new Microsoft.Graph.Error
                    {
                        Code    = Microsoft.Graph.GeneratedErrorConstants.Codes.NotAllowed,
                        Message = String.Format(Microsoft.Graph.GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, noncustodialDataSourceToUpdate.GetType().Name)
                    });
                }
            }
            if (noncustodialDataSourceToUpdate.AdditionalData != null)
            {
                if (noncustodialDataSourceToUpdate.AdditionalData.ContainsKey(Microsoft.Graph.Constants.HttpPropertyNames.ResponseHeaders) ||
                    noncustodialDataSourceToUpdate.AdditionalData.ContainsKey(Microsoft.Graph.Constants.HttpPropertyNames.StatusCode))
                {
                    throw new Microsoft.Graph.ClientException(
                              new Microsoft.Graph.Error
                    {
                        Code    = Microsoft.Graph.GeneratedErrorConstants.Codes.NotAllowed,
                        Message = String.Format(Microsoft.Graph.GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, noncustodialDataSourceToUpdate.GetType().Name)
                    });
                }
            }
            this.ContentType = "application/json";
            this.Method      = "PATCH";
            var updatedEntity = await this.SendAsync <NoncustodialDataSource>(noncustodialDataSourceToUpdate, cancellationToken).ConfigureAwait(false);

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