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

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

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

            this.InitializeCollectionProperties(updatedEntity);
            return(updatedEntity);
        }
Beispiel #4
0
        /// <summary>
        /// Adds the specified EducationSchool to the collection via POST.
        /// </summary>
        /// <param name="educationSchool">The EducationSchool 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(EducationSchool educationSchool, CancellationToken cancellationToken)
        {
            this.ContentType = "application/json";
            this.Method      = "POST";

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

            var requestBody = new ReferenceRequestBody {
                ODataId = string.Format("{0}/education/schools/{1}", this.Client.BaseUrl, educationSchool.Id)
            };

            return(this.SendAsync(requestBody, cancellationToken));
        }
Beispiel #5
0
        /// <summary>
        /// Initializes any collection properties after deserialization, like next requests for paging.
        /// </summary>
        /// <param name="educationSchoolToInitialize">The <see cref="EducationSchool"/> with the collection properties to initialize.</param>
        private void InitializeCollectionProperties(EducationSchool educationSchoolToInitialize)
        {
            if (educationSchoolToInitialize != null && educationSchoolToInitialize.AdditionalData != null)
            {
                if (educationSchoolToInitialize.Classes != null && educationSchoolToInitialize.Classes.CurrentPage != null)
                {
                    educationSchoolToInitialize.Classes.AdditionalData = educationSchoolToInitialize.AdditionalData;

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

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

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

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

                    if (!string.IsNullOrEmpty(nextPageLinkString))
                    {
                        educationSchoolToInitialize.Users.InitializeNextPageRequest(
                            this.Client,
                            nextPageLinkString);
                    }
                }
            }
        }
 /// <summary>
 /// Updates the specified EducationSchool using PATCH.
 /// </summary>
 /// <param name="educationSchoolToUpdate">The EducationSchool to update.</param>
 /// <returns>The updated EducationSchool.</returns>
 public System.Threading.Tasks.Task <EducationSchool> UpdateAsync(EducationSchool educationSchoolToUpdate)
 {
     return(this.UpdateAsync(educationSchoolToUpdate, CancellationToken.None));
 }
Beispiel #7
0
 /// <summary>
 /// Adds the specified EducationSchool to the collection via POST.
 /// </summary>
 /// <param name="educationSchool">The EducationSchool to add.</param>
 /// <returns>The task to await.</returns>
 public System.Threading.Tasks.Task AddAsync(EducationSchool educationSchool)
 {
     return(this.AddAsync(educationSchool, CancellationToken.None));
 }
 /// <summary>
 /// Adds the specified EducationSchool to the collection via POST.
 /// </summary>
 /// <param name="educationSchool">The EducationSchool to add.</param>
 /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
 /// <returns>The created EducationSchool.</returns>
 public System.Threading.Tasks.Task <EducationSchool> AddAsync(EducationSchool educationSchool, CancellationToken cancellationToken)
 {
     this.ContentType = "application/json";
     this.Method      = "POST";
     return(this.SendAsync <EducationSchool>(educationSchool, cancellationToken));
 }