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

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