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

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

                    if (!string.IsNullOrEmpty(nextPageLinkString))
                    {
                        managedDeviceMobileAppConfigurationToInitialize.Assignments.InitializeNextPageRequest(
                            this.Client,
                            nextPageLinkString);
                    }
                }

                if (managedDeviceMobileAppConfigurationToInitialize.DeviceStatuses != null && managedDeviceMobileAppConfigurationToInitialize.DeviceStatuses.CurrentPage != null)
                {
                    managedDeviceMobileAppConfigurationToInitialize.DeviceStatuses.AdditionalData = managedDeviceMobileAppConfigurationToInitialize.AdditionalData;

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

                    if (!string.IsNullOrEmpty(nextPageLinkString))
                    {
                        managedDeviceMobileAppConfigurationToInitialize.DeviceStatuses.InitializeNextPageRequest(
                            this.Client,
                            nextPageLinkString);
                    }
                }

                if (managedDeviceMobileAppConfigurationToInitialize.UserStatuses != null && managedDeviceMobileAppConfigurationToInitialize.UserStatuses.CurrentPage != null)
                {
                    managedDeviceMobileAppConfigurationToInitialize.UserStatuses.AdditionalData = managedDeviceMobileAppConfigurationToInitialize.AdditionalData;

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

                    if (!string.IsNullOrEmpty(nextPageLinkString))
                    {
                        managedDeviceMobileAppConfigurationToInitialize.UserStatuses.InitializeNextPageRequest(
                            this.Client,
                            nextPageLinkString);
                    }
                }
            }
        }
 /// <summary>
 /// Adds the specified ManagedDeviceMobileAppConfiguration to the collection via POST.
 /// </summary>
 /// <param name="managedDeviceMobileAppConfiguration">The ManagedDeviceMobileAppConfiguration to add.</param>
 /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
 /// <returns>The created ManagedDeviceMobileAppConfiguration.</returns>
 public System.Threading.Tasks.Task <ManagedDeviceMobileAppConfiguration> AddAsync(ManagedDeviceMobileAppConfiguration managedDeviceMobileAppConfiguration, CancellationToken cancellationToken)
 {
     this.ContentType = "application/json";
     this.Method      = "POST";
     managedDeviceMobileAppConfiguration.ODataType = string.Concat("#", StringHelper.ConvertTypeToLowerCamelCase(managedDeviceMobileAppConfiguration.GetType().FullName));
     return(this.SendAsync <ManagedDeviceMobileAppConfiguration>(managedDeviceMobileAppConfiguration, cancellationToken));
 }
 /// <summary>
 /// Adds the specified ManagedDeviceMobileAppConfiguration to the collection via POST.
 /// </summary>
 /// <param name="managedDeviceMobileAppConfiguration">The ManagedDeviceMobileAppConfiguration to add.</param>
 /// <returns>The created ManagedDeviceMobileAppConfiguration.</returns>
 public System.Threading.Tasks.Task <ManagedDeviceMobileAppConfiguration> AddAsync(ManagedDeviceMobileAppConfiguration managedDeviceMobileAppConfiguration)
 {
     return(this.AddAsync(managedDeviceMobileAppConfiguration, CancellationToken.None));
 }
Example #4
0
        /// <summary>
        /// Creates the specified ManagedDeviceMobileAppConfiguration using POST.
        /// </summary>
        /// <param name="managedDeviceMobileAppConfigurationToCreate">The ManagedDeviceMobileAppConfiguration to create.</param>
        /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
        /// <returns>The created ManagedDeviceMobileAppConfiguration.</returns>
        public async System.Threading.Tasks.Task <ManagedDeviceMobileAppConfiguration> CreateAsync(ManagedDeviceMobileAppConfiguration managedDeviceMobileAppConfigurationToCreate, CancellationToken cancellationToken)
        {
            this.ContentType = "application/json";
            this.Method      = "POST";
            var newEntity = await this.SendAsync <ManagedDeviceMobileAppConfiguration>(managedDeviceMobileAppConfigurationToCreate, cancellationToken).ConfigureAwait(false);

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

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