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

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

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

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

                    if (!string.IsNullOrEmpty(nextPageLinkString))
                    {
                        educationSubmissionToInitialize.Resources.InitializeNextPageRequest(
                            this.Client,
                            nextPageLinkString);
                    }
                }

                if (educationSubmissionToInitialize.SubmittedResources != null && educationSubmissionToInitialize.SubmittedResources.CurrentPage != null)
                {
                    educationSubmissionToInitialize.SubmittedResources.AdditionalData = educationSubmissionToInitialize.AdditionalData;

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

                    if (!string.IsNullOrEmpty(nextPageLinkString))
                    {
                        educationSubmissionToInitialize.SubmittedResources.InitializeNextPageRequest(
                            this.Client,
                            nextPageLinkString);
                    }
                }

                if (educationSubmissionToInitialize.Outcomes != null && educationSubmissionToInitialize.Outcomes.CurrentPage != null)
                {
                    educationSubmissionToInitialize.Outcomes.AdditionalData = educationSubmissionToInitialize.AdditionalData;

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

                    if (!string.IsNullOrEmpty(nextPageLinkString))
                    {
                        educationSubmissionToInitialize.Outcomes.InitializeNextPageRequest(
                            this.Client,
                            nextPageLinkString);
                    }
                }
            }
        }
 /// <summary>
 /// Adds the specified EducationSubmission to the collection via POST.
 /// </summary>
 /// <param name="educationSubmission">The EducationSubmission to add.</param>
 /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
 /// <returns>The created EducationSubmission.</returns>
 public System.Threading.Tasks.Task <EducationSubmission> AddAsync(EducationSubmission educationSubmission, CancellationToken cancellationToken)
 {
     this.ContentType = "application/json";
     this.Method      = "POST";
     return(this.SendAsync <EducationSubmission>(educationSubmission, cancellationToken));
 }
 /// <summary>
 /// Adds the specified EducationSubmission to the collection via POST.
 /// </summary>
 /// <param name="educationSubmission">The EducationSubmission to add.</param>
 /// <returns>The created EducationSubmission.</returns>
 public System.Threading.Tasks.Task <EducationSubmission> AddAsync(EducationSubmission educationSubmission)
 {
     return(this.AddAsync(educationSubmission, CancellationToken.None));
 }
Exemple #6
0
 /// <summary>
 /// Creates the specified EducationSubmission using POST.
 /// </summary>
 /// <param name="educationSubmissionToCreate">The EducationSubmission to create.</param>
 /// <returns>The created EducationSubmission.</returns>
 public System.Threading.Tasks.Task <EducationSubmission> CreateAsync(EducationSubmission educationSubmissionToCreate)
 {
     return(this.CreateAsync(educationSubmissionToCreate, CancellationToken.None));
 }