Beispiel #1
0
 /// <summary>
 /// Adds the specified AuthenticationMethod to the collection via POST.
 /// </summary>
 /// <param name="authenticationMethod">The AuthenticationMethod to add.</param>
 /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
 /// <returns>The created AuthenticationMethod.</returns>
 public System.Threading.Tasks.Task <AuthenticationMethod> AddAsync(AuthenticationMethod authenticationMethod, CancellationToken cancellationToken)
 {
     this.ContentType = "application/json";
     this.Method      = "POST";
     authenticationMethod.ODataType = string.Concat("#", StringHelper.ConvertTypeToLowerCamelCase(authenticationMethod.GetType().FullName));
     return(this.SendAsync <AuthenticationMethod>(authenticationMethod, cancellationToken));
 }
Beispiel #2
0
        /// <summary>
        /// Updates the specified AuthenticationMethod using PATCH.
        /// </summary>
        /// <param name="authenticationMethodToUpdate">The AuthenticationMethod 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 AuthenticationMethod.</returns>
        public async System.Threading.Tasks.Task <AuthenticationMethod> UpdateAsync(AuthenticationMethod authenticationMethodToUpdate, CancellationToken cancellationToken)
        {
            if (authenticationMethodToUpdate.AdditionalData != null)
            {
                if (authenticationMethodToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.ResponseHeaders) ||
                    authenticationMethodToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.StatusCode))
                {
                    throw new ClientException(
                              new Error
                    {
                        Code    = GeneratedErrorConstants.Codes.NotAllowed,
                        Message = String.Format(GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, authenticationMethodToUpdate.GetType().Name)
                    });
                }
            }
            if (authenticationMethodToUpdate.AdditionalData != null)
            {
                if (authenticationMethodToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.ResponseHeaders) ||
                    authenticationMethodToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.StatusCode))
                {
                    throw new ClientException(
                              new Error
                    {
                        Code    = GeneratedErrorConstants.Codes.NotAllowed,
                        Message = String.Format(GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, authenticationMethodToUpdate.GetType().Name)
                    });
                }
            }
            this.ContentType = "application/json";
            this.Method      = "PATCH";
            var updatedEntity = await this.SendAsync <AuthenticationMethod>(authenticationMethodToUpdate, cancellationToken).ConfigureAwait(false);

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