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

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

                    if (!string.IsNullOrEmpty(nextPageLinkString))
                    {
                        deviceAndAppManagementRoleAssignmentToInitialize.RoleScopeTags.InitializeNextPageRequest(
                            this.Client,
                            nextPageLinkString);
                    }
                }
            }
        }
        /// <summary>
        /// Creates the specified DeviceAndAppManagementRoleAssignment using POST.
        /// </summary>
        /// <param name="deviceAndAppManagementRoleAssignmentToCreate">The DeviceAndAppManagementRoleAssignment to create.</param>
        /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
        /// <returns>The created DeviceAndAppManagementRoleAssignment.</returns>
        public async System.Threading.Tasks.Task <DeviceAndAppManagementRoleAssignment> CreateAsync(DeviceAndAppManagementRoleAssignment deviceAndAppManagementRoleAssignmentToCreate, CancellationToken cancellationToken)
        {
            this.ContentType = "application/json";
            this.Method      = "POST";
            var newEntity = await this.SendAsync <DeviceAndAppManagementRoleAssignment>(deviceAndAppManagementRoleAssignmentToCreate, cancellationToken).ConfigureAwait(false);

            this.InitializeCollectionProperties(newEntity);
            return(newEntity);
        }
 /// <summary>
 /// Creates the specified DeviceAndAppManagementRoleAssignment using POST.
 /// </summary>
 /// <param name="deviceAndAppManagementRoleAssignmentToCreate">The DeviceAndAppManagementRoleAssignment to create.</param>
 /// <returns>The created DeviceAndAppManagementRoleAssignment.</returns>
 public System.Threading.Tasks.Task <DeviceAndAppManagementRoleAssignment> CreateAsync(DeviceAndAppManagementRoleAssignment deviceAndAppManagementRoleAssignmentToCreate)
 {
     return(this.CreateAsync(deviceAndAppManagementRoleAssignmentToCreate, CancellationToken.None));
 }
 /// <summary>
 /// Initializes any collection properties after deserialization, like next requests for paging.
 /// </summary>
 /// <param name="deviceAndAppManagementRoleAssignmentToInitialize">The <see cref="DeviceAndAppManagementRoleAssignment"/> with the collection properties to initialize.</param>
 private void InitializeCollectionProperties(DeviceAndAppManagementRoleAssignment deviceAndAppManagementRoleAssignmentToInitialize)
 {
 }
 /// <summary>
 /// Adds the specified DeviceAndAppManagementRoleAssignment to the collection via POST.
 /// </summary>
 /// <param name="deviceAndAppManagementRoleAssignment">The DeviceAndAppManagementRoleAssignment to add.</param>
 /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
 /// <returns>The created DeviceAndAppManagementRoleAssignment.</returns>
 public System.Threading.Tasks.Task <DeviceAndAppManagementRoleAssignment> AddAsync(DeviceAndAppManagementRoleAssignment deviceAndAppManagementRoleAssignment, CancellationToken cancellationToken)
 {
     this.ContentType = "application/json";
     this.Method      = "POST";
     return(this.SendAsync <DeviceAndAppManagementRoleAssignment>(deviceAndAppManagementRoleAssignment, cancellationToken));
 }
        /// <summary>
        /// Updates the specified DeviceAndAppManagementRoleAssignment using PATCH.
        /// </summary>
        /// <param name="deviceAndAppManagementRoleAssignmentToUpdate">The DeviceAndAppManagementRoleAssignment 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 DeviceAndAppManagementRoleAssignment.</returns>
        public async System.Threading.Tasks.Task <DeviceAndAppManagementRoleAssignment> UpdateAsync(DeviceAndAppManagementRoleAssignment deviceAndAppManagementRoleAssignmentToUpdate, CancellationToken cancellationToken)
        {
            if (deviceAndAppManagementRoleAssignmentToUpdate.AdditionalData != null)
            {
                if (deviceAndAppManagementRoleAssignmentToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.ResponseHeaders) ||
                    deviceAndAppManagementRoleAssignmentToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.StatusCode))
                {
                    throw new ClientException(
                              new Error
                    {
                        Code    = GeneratedErrorConstants.Codes.NotAllowed,
                        Message = String.Format(GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, deviceAndAppManagementRoleAssignmentToUpdate.GetType().Name)
                    });
                }
            }
            if (deviceAndAppManagementRoleAssignmentToUpdate.AdditionalData != null)
            {
                if (deviceAndAppManagementRoleAssignmentToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.ResponseHeaders) ||
                    deviceAndAppManagementRoleAssignmentToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.StatusCode))
                {
                    throw new ClientException(
                              new Error
                    {
                        Code    = GeneratedErrorConstants.Codes.NotAllowed,
                        Message = String.Format(GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, deviceAndAppManagementRoleAssignmentToUpdate.GetType().Name)
                    });
                }
            }
            this.ContentType = "application/json";
            this.Method      = "PATCH";
            var updatedEntity = await this.SendAsync <DeviceAndAppManagementRoleAssignment>(deviceAndAppManagementRoleAssignmentToUpdate, cancellationToken).ConfigureAwait(false);

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