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

            this.InitializeCollectionProperties(updatedEntity);
            return(updatedEntity);
        }
        /// <summary>
        /// Updates the specified MobileAppCategory using PATCH.
        /// </summary>
        /// <param name="mobileAppCategoryToUpdate">The MobileAppCategory to update.</param>
        /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
        /// <returns>The updated MobileAppCategory.</returns>
        public async System.Threading.Tasks.Task <MobileAppCategory> UpdateAsync(MobileAppCategory mobileAppCategoryToUpdate, CancellationToken cancellationToken)
        {
            this.ContentType = "application/json";
            this.Method      = "PATCH";
            var updatedEntity = await this.SendAsync <MobileAppCategory>(mobileAppCategoryToUpdate, cancellationToken).ConfigureAwait(false);

            return(updatedEntity);
        }
Пример #3
0
        /// <summary>
        /// Creates the specified MobileAppCategory using POST.
        /// </summary>
        /// <param name="mobileAppCategoryToCreate">The MobileAppCategory to create.</param>
        /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
        /// <returns>The created MobileAppCategory.</returns>
        public async System.Threading.Tasks.Task <MobileAppCategory> CreateAsync(MobileAppCategory mobileAppCategoryToCreate, CancellationToken cancellationToken)
        {
            this.ContentType = "application/json";
            this.Method      = "POST";
            var newEntity = await this.SendAsync <MobileAppCategory>(mobileAppCategoryToCreate, cancellationToken).ConfigureAwait(false);

            this.InitializeCollectionProperties(newEntity);
            return(newEntity);
        }
Пример #4
0
        /// <summary>
        /// Adds the specified MobileAppCategory to the collection via POST.
        /// </summary>
        /// <param name="mobileAppCategory">The MobileAppCategory 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(MobileAppCategory mobileAppCategory, CancellationToken cancellationToken)
        {
            this.ContentType = "application/json";
            this.Method      = "POST";

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

            var requestBody = new ReferenceRequestBody {
                ODataId = string.Format("{0}/deviceAppManagement/categories/{1}", this.Client.BaseUrl, mobileAppCategory.Id)
            };

            return(this.SendAsync(requestBody, cancellationToken));
        }
Пример #5
0
 /// <summary>
 /// Adds the specified MobileAppCategory to the collection via POST.
 /// </summary>
 /// <param name="mobileAppCategory">The MobileAppCategory to add.</param>
 /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
 /// <returns>The created MobileAppCategory.</returns>
 public System.Threading.Tasks.Task <MobileAppCategory> AddAsync(MobileAppCategory mobileAppCategory, CancellationToken cancellationToken)
 {
     this.ContentType = "application/json";
     this.Method      = "POST";
     return(this.SendAsync <MobileAppCategory>(mobileAppCategory, cancellationToken));
 }
Пример #6
0
 /// <summary>
 /// Adds the specified MobileAppCategory to the collection via POST.
 /// </summary>
 /// <param name="mobileAppCategory">The MobileAppCategory to add.</param>
 /// <returns>The created MobileAppCategory.</returns>
 public System.Threading.Tasks.Task <MobileAppCategory> AddAsync(MobileAppCategory mobileAppCategory)
 {
     return(this.AddAsync(mobileAppCategory, CancellationToken.None));
 }
 /// <summary>
 /// Updates the specified MobileAppCategory using PATCH.
 /// </summary>
 /// <param name="mobileAppCategoryToUpdate">The MobileAppCategory to update.</param>
 /// <returns>The updated MobileAppCategory.</returns>
 public System.Threading.Tasks.Task <MobileAppCategory> UpdateAsync(MobileAppCategory mobileAppCategoryToUpdate)
 {
     return(this.UpdateAsync(mobileAppCategoryToUpdate, CancellationToken.None));
 }
Пример #8
0
 /// <summary>
 /// Initializes any collection properties after deserialization, like next requests for paging.
 /// </summary>
 /// <param name="mobileAppCategoryToInitialize">The <see cref="MobileAppCategory"/> with the collection properties to initialize.</param>
 private void InitializeCollectionProperties(MobileAppCategory mobileAppCategoryToInitialize)
 {
 }