/// <summary> /// Initializes any collection properties after deserialization, like next requests for paging. /// </summary> /// <param name="deviceManagementCollectionSettingInstanceToInitialize">The <see cref="DeviceManagementCollectionSettingInstance"/> with the collection properties to initialize.</param> private void InitializeCollectionProperties(DeviceManagementCollectionSettingInstance deviceManagementCollectionSettingInstanceToInitialize) { if (deviceManagementCollectionSettingInstanceToInitialize != null && deviceManagementCollectionSettingInstanceToInitialize.AdditionalData != null) { if (deviceManagementCollectionSettingInstanceToInitialize.Value != null && deviceManagementCollectionSettingInstanceToInitialize.Value.CurrentPage != null) { deviceManagementCollectionSettingInstanceToInitialize.Value.AdditionalData = deviceManagementCollectionSettingInstanceToInitialize.AdditionalData; object nextPageLink; deviceManagementCollectionSettingInstanceToInitialize.AdditionalData.TryGetValue("*****@*****.**", out nextPageLink); var nextPageLinkString = nextPageLink as string; if (!string.IsNullOrEmpty(nextPageLinkString)) { deviceManagementCollectionSettingInstanceToInitialize.Value.InitializeNextPageRequest( this.Client, nextPageLinkString); } } } }
/// <summary> /// Creates the specified DeviceManagementCollectionSettingInstance using POST. /// </summary> /// <param name="deviceManagementCollectionSettingInstanceToCreate">The DeviceManagementCollectionSettingInstance to create.</param> /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param> /// <returns>The created DeviceManagementCollectionSettingInstance.</returns> public async System.Threading.Tasks.Task <DeviceManagementCollectionSettingInstance> CreateAsync(DeviceManagementCollectionSettingInstance deviceManagementCollectionSettingInstanceToCreate, CancellationToken cancellationToken) { this.ContentType = "application/json"; this.Method = "POST"; var newEntity = await this.SendAsync <DeviceManagementCollectionSettingInstance>(deviceManagementCollectionSettingInstanceToCreate, cancellationToken).ConfigureAwait(false); this.InitializeCollectionProperties(newEntity); return(newEntity); }
/// <summary> /// Creates the specified DeviceManagementCollectionSettingInstance using POST. /// </summary> /// <param name="deviceManagementCollectionSettingInstanceToCreate">The DeviceManagementCollectionSettingInstance to create.</param> /// <returns>The created DeviceManagementCollectionSettingInstance.</returns> public System.Threading.Tasks.Task <DeviceManagementCollectionSettingInstance> CreateAsync(DeviceManagementCollectionSettingInstance deviceManagementCollectionSettingInstanceToCreate) { return(this.CreateAsync(deviceManagementCollectionSettingInstanceToCreate, CancellationToken.None)); }
/// <summary> /// Updates the specified DeviceManagementCollectionSettingInstance using PATCH. /// </summary> /// <param name="deviceManagementCollectionSettingInstanceToUpdate">The DeviceManagementCollectionSettingInstance 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 DeviceManagementCollectionSettingInstance.</returns> public async System.Threading.Tasks.Task <DeviceManagementCollectionSettingInstance> UpdateAsync(DeviceManagementCollectionSettingInstance deviceManagementCollectionSettingInstanceToUpdate, CancellationToken cancellationToken) { if (deviceManagementCollectionSettingInstanceToUpdate.AdditionalData != null) { if (deviceManagementCollectionSettingInstanceToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.ResponseHeaders) || deviceManagementCollectionSettingInstanceToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.StatusCode)) { throw new ClientException( new Error { Code = GeneratedErrorConstants.Codes.NotAllowed, Message = String.Format(GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, deviceManagementCollectionSettingInstanceToUpdate.GetType().Name) }); } } if (deviceManagementCollectionSettingInstanceToUpdate.AdditionalData != null) { if (deviceManagementCollectionSettingInstanceToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.ResponseHeaders) || deviceManagementCollectionSettingInstanceToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.StatusCode)) { throw new ClientException( new Error { Code = GeneratedErrorConstants.Codes.NotAllowed, Message = String.Format(GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, deviceManagementCollectionSettingInstanceToUpdate.GetType().Name) }); } } this.ContentType = "application/json"; this.Method = "PATCH"; var updatedEntity = await this.SendAsync <DeviceManagementCollectionSettingInstance>(deviceManagementCollectionSettingInstanceToUpdate, cancellationToken).ConfigureAwait(false); this.InitializeCollectionProperties(updatedEntity); return(updatedEntity); }