/// <summary> /// Creates the specified ManagedTenant using POST. /// </summary> /// <param name="managedTenantToCreate">The ManagedTenant to create.</param> /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param> /// <returns>The created ManagedTenant.</returns> public async System.Threading.Tasks.Task <ManagedTenant> CreateAsync(ManagedTenant managedTenantToCreate, CancellationToken cancellationToken = default) { this.ContentType = CoreConstants.MimeTypeNames.Application.Json; this.Method = HttpMethods.POST; var newEntity = await this.SendAsync <ManagedTenant>(managedTenantToCreate, cancellationToken).ConfigureAwait(false); this.InitializeCollectionProperties(newEntity); return(newEntity); }
/// <summary> /// Initializes any collection properties after deserialization, like next requests for paging. /// </summary> /// <param name="managedTenantToInitialize">The <see cref="ManagedTenant"/> with the collection properties to initialize.</param> private void InitializeCollectionProperties(ManagedTenant managedTenantToInitialize) { if (managedTenantToInitialize != null) { if (managedTenantToInitialize.ManagementTemplateCollections != null && managedTenantToInitialize.ManagementTemplateCollections.CurrentPage != null) { managedTenantToInitialize.ManagementTemplateCollections.InitializeNextPageRequest(this.Client, managedTenantToInitialize.ManagementTemplateCollectionsNextLink); // Copy the additional data collection to the page itself so that information is not lost managedTenantToInitialize.ManagementTemplateCollections.AdditionalData = managedTenantToInitialize.AdditionalData; } if (managedTenantToInitialize.ManagementTemplates != null && managedTenantToInitialize.ManagementTemplates.CurrentPage != null) { managedTenantToInitialize.ManagementTemplates.InitializeNextPageRequest(this.Client, managedTenantToInitialize.ManagementTemplatesNextLink); // Copy the additional data collection to the page itself so that information is not lost managedTenantToInitialize.ManagementTemplates.AdditionalData = managedTenantToInitialize.AdditionalData; } } }
/// <summary> /// Creates the specified ManagedTenant using POST and returns a <see cref="GraphResponse{ManagedTenant}"/> object. /// </summary> /// <param name="managedTenantToCreate">The ManagedTenant to create.</param> /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param> /// <returns>The <see cref="GraphResponse{ManagedTenant}"/> object of the request.</returns> public System.Threading.Tasks.Task <GraphResponse <ManagedTenant> > CreateResponseAsync(ManagedTenant managedTenantToCreate, CancellationToken cancellationToken = default) { this.ContentType = CoreConstants.MimeTypeNames.Application.Json; this.Method = HttpMethods.POST; return(this.SendAsyncWithGraphResponse <ManagedTenant>(managedTenantToCreate, cancellationToken)); }