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

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

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

            this.InitializeCollectionProperties(newEntity);
            return(newEntity);
        }
コード例 #4
0
        /// <summary>
        /// Initializes any collection properties after deserialization, like next requests for paging.
        /// </summary>
        /// <param name="educationClassToInitialize">The <see cref="EducationClass"/> with the collection properties to initialize.</param>
        private void InitializeCollectionProperties(EducationClass educationClassToInitialize)
        {
            if (educationClassToInitialize != null && educationClassToInitialize.AdditionalData != null)
            {
                if (educationClassToInitialize.Schools != null && educationClassToInitialize.Schools.CurrentPage != null)
                {
                    educationClassToInitialize.Schools.AdditionalData = educationClassToInitialize.AdditionalData;

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

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

                if (educationClassToInitialize.Members != null && educationClassToInitialize.Members.CurrentPage != null)
                {
                    educationClassToInitialize.Members.AdditionalData = educationClassToInitialize.AdditionalData;

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

                    if (!string.IsNullOrEmpty(nextPageLinkString))
                    {
                        educationClassToInitialize.Members.InitializeNextPageRequest(
                            this.Client,
                            nextPageLinkString);
                    }
                }

                if (educationClassToInitialize.Teachers != null && educationClassToInitialize.Teachers.CurrentPage != null)
                {
                    educationClassToInitialize.Teachers.AdditionalData = educationClassToInitialize.AdditionalData;

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

                    if (!string.IsNullOrEmpty(nextPageLinkString))
                    {
                        educationClassToInitialize.Teachers.InitializeNextPageRequest(
                            this.Client,
                            nextPageLinkString);
                    }
                }
            }
        }
        /// <summary>
        /// Adds the specified EducationClass to the collection via POST.
        /// </summary>
        /// <param name="educationClass">The EducationClass 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(EducationClass educationClass, CancellationToken cancellationToken)
        {
            this.ContentType = "application/json";
            this.Method      = "POST";

            if (string.IsNullOrEmpty(educationClass.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/classes/{1}", this.Client.BaseUrl, educationClass.Id)
            };

            return(this.SendAsync(requestBody, cancellationToken));
        }
コード例 #6
0
 /// <summary>
 /// Creates the specified EducationClass using POST.
 /// </summary>
 /// <param name="educationClassToCreate">The EducationClass to create.</param>
 /// <returns>The created EducationClass.</returns>
 public System.Threading.Tasks.Task <EducationClass> CreateAsync(EducationClass educationClassToCreate)
 {
     return(this.CreateAsync(educationClassToCreate, CancellationToken.None));
 }
 /// <summary>
 /// Adds the specified EducationClass to the collection via POST.
 /// </summary>
 /// <param name="educationClass">The EducationClass to add.</param>
 /// <returns>The task to await.</returns>
 public System.Threading.Tasks.Task AddAsync(EducationClass educationClass)
 {
     return(this.AddAsync(educationClass, CancellationToken.None));
 }
コード例 #8
0
 /// <summary>
 /// Adds the specified EducationClass to the collection via POST.
 /// </summary>
 /// <param name="educationClass">The EducationClass to add.</param>
 /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
 /// <returns>The created EducationClass.</returns>
 public System.Threading.Tasks.Task <EducationClass> AddAsync(EducationClass educationClass, CancellationToken cancellationToken)
 {
     this.ContentType = "application/json";
     this.Method      = "POST";
     return(this.SendAsync <EducationClass>(educationClass, cancellationToken));
 }