コード例 #1
0
        /// <summary>
        /// Adds the specified ManagementConditionStatement to the collection via POST.
        /// </summary>
        /// <param name="managementConditionStatement">The ManagementConditionStatement to add.</param>
        /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
        /// <returns>The task to await.</returns>
        public System.Threading.Tasks.Task AddAsync(ManagementConditionStatement managementConditionStatement, CancellationToken cancellationToken)
        {
            this.ContentType = "application/json";
            this.Method      = "POST";

            if (string.IsNullOrEmpty(managementConditionStatement.Id))
            {
                throw new ServiceException(new Error {
                    Code = "invalidRequest", Message = "ID is required to add a reference."
                });
            }

            var requestBody = new ReferenceRequestBody {
                ODataId = string.Format("{0}/deviceManagement/managementConditionStatements/{1}", this.Client.BaseUrl, managementConditionStatement.Id)
            };

            return(this.SendAsync(requestBody, cancellationToken));
        }
コード例 #2
0
        /// <summary>
        /// Initializes any collection properties after deserialization, like next requests for paging.
        /// </summary>
        /// <param name="managementConditionStatementToInitialize">The <see cref="ManagementConditionStatement"/> with the collection properties to initialize.</param>
        private void InitializeCollectionProperties(ManagementConditionStatement managementConditionStatementToInitialize)
        {
            if (managementConditionStatementToInitialize != null && managementConditionStatementToInitialize.AdditionalData != null)
            {
                if (managementConditionStatementToInitialize.ManagementConditions != null && managementConditionStatementToInitialize.ManagementConditions.CurrentPage != null)
                {
                    managementConditionStatementToInitialize.ManagementConditions.AdditionalData = managementConditionStatementToInitialize.AdditionalData;

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

                    if (!string.IsNullOrEmpty(nextPageLinkString))
                    {
                        managementConditionStatementToInitialize.ManagementConditions.InitializeNextPageRequest(
                            this.Client,
                            nextPageLinkString);
                    }
                }
            }
        }
 /// <summary>
 /// Updates the specified ManagementConditionStatement using PATCH.
 /// </summary>
 /// <param name="managementConditionStatementToUpdate">The ManagementConditionStatement to update.</param>
 /// <returns>The updated ManagementConditionStatement.</returns>
 public System.Threading.Tasks.Task <ManagementConditionStatement> UpdateAsync(ManagementConditionStatement managementConditionStatementToUpdate)
 {
     return(this.UpdateAsync(managementConditionStatementToUpdate, CancellationToken.None));
 }
        /// <summary>
        /// Creates the specified ManagementConditionStatement using POST.
        /// </summary>
        /// <param name="managementConditionStatementToCreate">The ManagementConditionStatement to create.</param>
        /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
        /// <returns>The created ManagementConditionStatement.</returns>
        public async System.Threading.Tasks.Task <ManagementConditionStatement> CreateAsync(ManagementConditionStatement managementConditionStatementToCreate, CancellationToken cancellationToken)
        {
            this.ContentType = "application/json";
            this.Method      = "POST";
            var newEntity = await this.SendAsync <ManagementConditionStatement>(managementConditionStatementToCreate, cancellationToken).ConfigureAwait(false);

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

            return(updatedEntity);
        }
コード例 #6
0
 /// <summary>
 /// Adds the specified ManagementConditionStatement to the collection via POST.
 /// </summary>
 /// <param name="managementConditionStatement">The ManagementConditionStatement to add.</param>
 /// <returns>The task to await.</returns>
 public System.Threading.Tasks.Task AddAsync(ManagementConditionStatement managementConditionStatement)
 {
     return(this.AddAsync(managementConditionStatement, CancellationToken.None));
 }
 /// <summary>
 /// Adds the specified ManagementConditionStatement to the collection via POST.
 /// </summary>
 /// <param name="managementConditionStatement">The ManagementConditionStatement to add.</param>
 /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
 /// <returns>The created ManagementConditionStatement.</returns>
 public System.Threading.Tasks.Task <ManagementConditionStatement> AddAsync(ManagementConditionStatement managementConditionStatement, CancellationToken cancellationToken)
 {
     this.ContentType = "application/json";
     this.Method      = "POST";
     return(this.SendAsync <ManagementConditionStatement>(managementConditionStatement, cancellationToken));
 }