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

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