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

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

            return(newEntity);
        }
コード例 #3
0
        /// <summary>
        /// Updates the specified EntityType2 using PATCH.
        /// </summary>
        /// <param name="entityType2ToUpdate">The EntityType2 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 EntityType2.</returns>
        public async System.Threading.Tasks.Task <EntityType2> UpdateAsync(EntityType2 entityType2ToUpdate, CancellationToken cancellationToken = default)
        {
            this.ContentType = CoreConstants.MimeTypeNames.Application.Json;
            this.Method      = HttpMethods.PATCH;
            var updatedEntity = await this.SendAsync <EntityType2>(entityType2ToUpdate, cancellationToken).ConfigureAwait(false);

            return(updatedEntity);
        }
コード例 #4
0
        /// <summary>
        /// Creates the specified EntityType2 using POST.
        /// </summary>
        /// <param name="entityType2ToCreate">The EntityType2 to create.</param>
        /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
        /// <returns>The created EntityType2.</returns>
        public async System.Threading.Tasks.Task <EntityType2> CreateAsync(EntityType2 entityType2ToCreate, CancellationToken cancellationToken = default)
        {
            this.ContentType = CoreConstants.MimeTypeNames.Application.Json;
            this.Method      = HttpMethods.POST;
            var newEntity = await this.SendAsync <EntityType2>(entityType2ToCreate, cancellationToken).ConfigureAwait(false);

            this.InitializeCollectionProperties(newEntity);
            return(newEntity);
        }
 /// <summary>
 /// Updates the specified EntityType2 using PATCH.
 /// </summary>
 /// <param name="entityType2ToUpdate">The EntityType2 to update.</param>
 /// <returns>The updated EntityType2.</returns>
 public System.Threading.Tasks.Task <EntityType2> UpdateAsync(EntityType2 entityType2ToUpdate)
 {
     return(this.UpdateAsync(entityType2ToUpdate, CancellationToken.None));
 }
コード例 #6
0
 /// <summary>
 /// Creates the specified EntityType2 using POST and returns a <see cref="GraphResponse{EntityType2}"/> object.
 /// </summary>
 /// <param name="entityType2ToCreate">The EntityType2 to create.</param>
 /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
 /// <returns>The <see cref="GraphResponse{EntityType2}"/> object of the request.</returns>
 public System.Threading.Tasks.Task <GraphResponse <EntityType2> > CreateResponseAsync(EntityType2 entityType2ToCreate, CancellationToken cancellationToken = default)
 {
     this.ContentType = CoreConstants.MimeTypeNames.Application.Json;
     this.Method      = HttpMethods.POST;
     return(this.SendAsyncWithGraphResponse <EntityType2>(entityType2ToCreate, cancellationToken));
 }
コード例 #7
0
 /// <summary>
 /// Initializes any collection properties after deserialization, like next requests for paging.
 /// </summary>
 /// <param name="entityType2ToInitialize">The <see cref="EntityType2"/> with the collection properties to initialize.</param>
 private void InitializeCollectionProperties(EntityType2 entityType2ToInitialize)
 {
 }