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

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

            this.InitializeCollectionProperties(newEntity);
            return(newEntity);
        }
 /// <summary>
 /// Adds the specified DeviceInstallState to the collection via POST.
 /// </summary>
 /// <param name="deviceInstallState">The DeviceInstallState to add.</param>
 /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
 /// <returns>The created DeviceInstallState.</returns>
 public System.Threading.Tasks.Task <DeviceInstallState> AddAsync(DeviceInstallState deviceInstallState, CancellationToken cancellationToken)
 {
     this.ContentType = "application/json";
     this.Method      = "POST";
     return(this.SendAsync <DeviceInstallState>(deviceInstallState, cancellationToken));
 }
 /// <summary>
 /// Adds the specified DeviceInstallState to the collection via POST.
 /// </summary>
 /// <param name="deviceInstallState">The DeviceInstallState to add.</param>
 /// <returns>The created DeviceInstallState.</returns>
 public System.Threading.Tasks.Task <DeviceInstallState> AddAsync(DeviceInstallState deviceInstallState)
 {
     return(this.AddAsync(deviceInstallState, CancellationToken.None));
 }
 /// <summary>
 /// Initializes any collection properties after deserialization, like next requests for paging.
 /// </summary>
 /// <param name="deviceInstallStateToInitialize">The <see cref="DeviceInstallState"/> with the collection properties to initialize.</param>
 private void InitializeCollectionProperties(DeviceInstallState deviceInstallStateToInitialize)
 {
 }