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

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

            this.InitializeCollectionProperties(newEntity);
            return(newEntity);
        }
        /// <summary>
        /// Initializes any collection properties after deserialization, like next requests for paging.
        /// </summary>
        /// <param name="ediscoveryrootToInitialize">The <see cref="Ediscoveryroot"/> with the collection properties to initialize.</param>
        private void InitializeCollectionProperties(Ediscoveryroot ediscoveryrootToInitialize)
        {
            if (ediscoveryrootToInitialize != null && ediscoveryrootToInitialize.AdditionalData != null)
            {
                if (ediscoveryrootToInitialize.Cases != null && ediscoveryrootToInitialize.Cases.CurrentPage != null)
                {
                    ediscoveryrootToInitialize.Cases.AdditionalData = ediscoveryrootToInitialize.AdditionalData;

                    object nextPageLink;
                    ediscoveryrootToInitialize.AdditionalData.TryGetValue("*****@*****.**", out nextPageLink);
                    var nextPageLinkString = nextPageLink as string;

                    if (!string.IsNullOrEmpty(nextPageLinkString))
                    {
                        ediscoveryrootToInitialize.Cases.InitializeNextPageRequest(
                            this.Client,
                            nextPageLinkString);
                    }
                }
            }
        }
 /// <summary>
 /// Creates the specified Ediscoveryroot using POST.
 /// </summary>
 /// <param name="ediscoveryrootToCreate">The Ediscoveryroot to create.</param>
 /// <returns>The created Ediscoveryroot.</returns>
 public System.Threading.Tasks.Task <Ediscoveryroot> CreateAsync(Ediscoveryroot ediscoveryrootToCreate)
 {
     return(this.CreateAsync(ediscoveryrootToCreate, CancellationToken.None));
 }