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

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

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

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

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