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

            this.InitializeCollectionProperties(newEntity);
            return(newEntity);
        }
        /// <summary>
        /// Updates the specified ManagementTemplateCollection using PATCH.
        /// </summary>
        /// <param name="managementTemplateCollectionToUpdate">The ManagementTemplateCollection to update.</param>
        /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
        /// <exception cref="Microsoft.Graph.ClientException">Thrown when an object returned in a response is used for updating an object in Microsoft Graph.</exception>
        /// <returns>The updated ManagementTemplateCollection.</returns>
        public async System.Threading.Tasks.Task <ManagementTemplateCollection> UpdateAsync(ManagementTemplateCollection managementTemplateCollectionToUpdate, CancellationToken cancellationToken = default)
        {
            this.ContentType = CoreConstants.MimeTypeNames.Application.Json;
            this.Method      = HttpMethods.PATCH;
            var updatedEntity = await this.SendAsync <ManagementTemplateCollection>(managementTemplateCollectionToUpdate, cancellationToken).ConfigureAwait(false);

            return(updatedEntity);
        }