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

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

            return(newEntity);
        }
Example #3
0
        /// <summary>
        /// Adds the specified ManagedEBookCategory to the collection via POST.
        /// </summary>
        /// <param name="managedEBookCategory">The ManagedEBookCategory 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(ManagedEBookCategory managedEBookCategory, CancellationToken cancellationToken)
        {
            this.ContentType = "application/json";
            this.Method      = "POST";

            if (string.IsNullOrEmpty(managedEBookCategory.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, managedEBookCategory.Id)
            };

            return(this.SendAsync(requestBody, cancellationToken));
        }
Example #4
0
 /// <summary>
 /// Updates the specified ManagedEBookCategory using PATCH.
 /// </summary>
 /// <param name="managedEBookCategoryToUpdate">The ManagedEBookCategory to update.</param>
 /// <returns>The updated ManagedEBookCategory.</returns>
 public System.Threading.Tasks.Task <ManagedEBookCategory> UpdateAsync(ManagedEBookCategory managedEBookCategoryToUpdate)
 {
     return(this.UpdateAsync(managedEBookCategoryToUpdate, CancellationToken.None));
 }
 /// <summary>
 /// Adds the specified ManagedEBookCategory to the collection via POST.
 /// </summary>
 /// <param name="managedEBookCategory">The ManagedEBookCategory to add.</param>
 /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
 /// <returns>The created ManagedEBookCategory.</returns>
 public System.Threading.Tasks.Task <ManagedEBookCategory> AddAsync(ManagedEBookCategory managedEBookCategory, CancellationToken cancellationToken)
 {
     this.ContentType = "application/json";
     this.Method      = "POST";
     return(this.SendAsync <ManagedEBookCategory>(managedEBookCategory, cancellationToken));
 }
 /// <summary>
 /// Adds the specified ManagedEBookCategory to the collection via POST.
 /// </summary>
 /// <param name="managedEBookCategory">The ManagedEBookCategory to add.</param>
 /// <returns>The created ManagedEBookCategory.</returns>
 public System.Threading.Tasks.Task <ManagedEBookCategory> AddAsync(ManagedEBookCategory managedEBookCategory)
 {
     return(this.AddAsync(managedEBookCategory, CancellationToken.None));
 }
 /// <summary>
 /// Initializes any collection properties after deserialization, like next requests for paging.
 /// </summary>
 /// <param name="managedEBookCategoryToInitialize">The <see cref="ManagedEBookCategory"/> with the collection properties to initialize.</param>
 private void InitializeCollectionProperties(ManagedEBookCategory managedEBookCategoryToInitialize)
 {
 }