예제 #1
0
 /// <summary>
 /// Adds the specified AndroidForWorkEnrollmentProfile to the collection via POST.
 /// </summary>
 /// <param name="androidForWorkEnrollmentProfile">The AndroidForWorkEnrollmentProfile to add.</param>
 /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
 /// <returns>The created AndroidForWorkEnrollmentProfile.</returns>
 public System.Threading.Tasks.Task <AndroidForWorkEnrollmentProfile> AddAsync(AndroidForWorkEnrollmentProfile androidForWorkEnrollmentProfile, CancellationToken cancellationToken)
 {
     this.ContentType = "application/json";
     this.Method      = "POST";
     return(this.SendAsync <AndroidForWorkEnrollmentProfile>(androidForWorkEnrollmentProfile, cancellationToken));
 }
예제 #2
0
 /// <summary>
 /// Adds the specified AndroidForWorkEnrollmentProfile to the collection via POST.
 /// </summary>
 /// <param name="androidForWorkEnrollmentProfile">The AndroidForWorkEnrollmentProfile to add.</param>
 /// <returns>The created AndroidForWorkEnrollmentProfile.</returns>
 public System.Threading.Tasks.Task <AndroidForWorkEnrollmentProfile> AddAsync(AndroidForWorkEnrollmentProfile androidForWorkEnrollmentProfile)
 {
     return(this.AddAsync(androidForWorkEnrollmentProfile, CancellationToken.None));
 }
 /// <summary>
 /// Initializes any collection properties after deserialization, like next requests for paging.
 /// </summary>
 /// <param name="androidForWorkEnrollmentProfileToInitialize">The <see cref="AndroidForWorkEnrollmentProfile"/> with the collection properties to initialize.</param>
 private void InitializeCollectionProperties(AndroidForWorkEnrollmentProfile androidForWorkEnrollmentProfileToInitialize)
 {
 }
        /// <summary>
        /// Creates the specified AndroidForWorkEnrollmentProfile using POST.
        /// </summary>
        /// <param name="androidForWorkEnrollmentProfileToCreate">The AndroidForWorkEnrollmentProfile to create.</param>
        /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
        /// <returns>The created AndroidForWorkEnrollmentProfile.</returns>
        public async System.Threading.Tasks.Task <AndroidForWorkEnrollmentProfile> CreateAsync(AndroidForWorkEnrollmentProfile androidForWorkEnrollmentProfileToCreate, CancellationToken cancellationToken)
        {
            this.ContentType = "application/json";
            this.Method      = "POST";
            var newEntity = await this.SendAsync <AndroidForWorkEnrollmentProfile>(androidForWorkEnrollmentProfileToCreate, cancellationToken).ConfigureAwait(false);

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

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