示例#1
0
        /// <summary>
        /// Updates the specified SingletonEntity1 using PATCH.
        /// </summary>
        /// <param name="singletonEntity1ToUpdate">The SingletonEntity1 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 SingletonEntity1.</returns>
        public async System.Threading.Tasks.Task <SingletonEntity1> UpdateAsync(SingletonEntity1 singletonEntity1ToUpdate, CancellationToken cancellationToken)
        {
            if (singletonEntity1ToUpdate.AdditionalData != null)
            {
                if (singletonEntity1ToUpdate.AdditionalData.ContainsKey(Microsoft.Graph.Constants.HttpPropertyNames.ResponseHeaders) ||
                    singletonEntity1ToUpdate.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, singletonEntity1ToUpdate.GetType().Name)
                    });
                }
            }
            if (singletonEntity1ToUpdate.AdditionalData != null)
            {
                if (singletonEntity1ToUpdate.AdditionalData.ContainsKey(Microsoft.Graph.Constants.HttpPropertyNames.ResponseHeaders) ||
                    singletonEntity1ToUpdate.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, singletonEntity1ToUpdate.GetType().Name)
                    });
                }
            }
            this.ContentType = "application/json";
            this.Method      = "PATCH";
            var updatedEntity = await this.SendAsync <SingletonEntity1>(singletonEntity1ToUpdate, cancellationToken).ConfigureAwait(false);

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

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

            this.InitializeCollectionProperties(newEntity);
            return(newEntity);
        }
 /// <summary>
 /// Creates the specified SingletonEntity1 using POST and returns a <see cref="GraphResponse{SingletonEntity1}"/> object.
 /// </summary>
 /// <param name="singletonEntity1ToCreate">The SingletonEntity1 to create.</param>
 /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
 /// <returns>The <see cref="GraphResponse{SingletonEntity1}"/> object of the request.</returns>
 public System.Threading.Tasks.Task <GraphResponse <SingletonEntity1> > CreateResponseAsync(SingletonEntity1 singletonEntity1ToCreate, CancellationToken cancellationToken = default)
 {
     this.ContentType = CoreConstants.MimeTypeNames.Application.Json;
     this.Method      = HttpMethods.POST;
     return(this.SendAsyncWithGraphResponse <SingletonEntity1>(singletonEntity1ToCreate, cancellationToken));
 }
 /// <summary>
 /// Initializes any collection properties after deserialization, like next requests for paging.
 /// </summary>
 /// <param name="singletonEntity1ToInitialize">The <see cref="SingletonEntity1"/> with the collection properties to initialize.</param>
 private void InitializeCollectionProperties(SingletonEntity1 singletonEntity1ToInitialize)
 {
 }
示例#6
0
 /// <summary>
 /// Creates the specified SingletonEntity1 using POST.
 /// </summary>
 /// <param name="singletonEntity1ToCreate">The SingletonEntity1 to create.</param>
 /// <returns>The created SingletonEntity1.</returns>
 public System.Threading.Tasks.Task <SingletonEntity1> CreateAsync(SingletonEntity1 singletonEntity1ToCreate)
 {
     return(this.CreateAsync(singletonEntity1ToCreate, CancellationToken.None));
 }