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

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

            this.InitializeCollectionProperties(newEntity);
            return(newEntity);
        }
Пример #3
0
        /// <summary>
        /// Initializes any collection properties after deserialization, like next requests for paging.
        /// </summary>
        /// <param name="educationRootToInitialize">The <see cref="EducationRoot"/> with the collection properties to initialize.</param>
        private void InitializeCollectionProperties(EducationRoot educationRootToInitialize)
        {
            if (educationRootToInitialize != null && educationRootToInitialize.AdditionalData != null)
            {
                if (educationRootToInitialize.Classes != null && educationRootToInitialize.Classes.CurrentPage != null)
                {
                    educationRootToInitialize.Classes.AdditionalData = educationRootToInitialize.AdditionalData;

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

                    if (!string.IsNullOrEmpty(nextPageLinkString))
                    {
                        educationRootToInitialize.Classes.InitializeNextPageRequest(
                            this.Client,
                            nextPageLinkString);
                    }
                }

                if (educationRootToInitialize.Schools != null && educationRootToInitialize.Schools.CurrentPage != null)
                {
                    educationRootToInitialize.Schools.AdditionalData = educationRootToInitialize.AdditionalData;

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

                    if (!string.IsNullOrEmpty(nextPageLinkString))
                    {
                        educationRootToInitialize.Schools.InitializeNextPageRequest(
                            this.Client,
                            nextPageLinkString);
                    }
                }

                if (educationRootToInitialize.Users != null && educationRootToInitialize.Users.CurrentPage != null)
                {
                    educationRootToInitialize.Users.AdditionalData = educationRootToInitialize.AdditionalData;

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

                    if (!string.IsNullOrEmpty(nextPageLinkString))
                    {
                        educationRootToInitialize.Users.InitializeNextPageRequest(
                            this.Client,
                            nextPageLinkString);
                    }
                }
            }
        }
Пример #4
0
 /// <summary>
 /// Creates the specified EducationRoot using POST.
 /// </summary>
 /// <param name="educationRootToCreate">The EducationRoot to create.</param>
 /// <returns>The created EducationRoot.</returns>
 public System.Threading.Tasks.Task <EducationRoot> CreateAsync(EducationRoot educationRootToCreate)
 {
     return(this.CreateAsync(educationRootToCreate, CancellationToken.None));
 }