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

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

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

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

                    if (!string.IsNullOrEmpty(nextPageLinkString))
                    {
                        educationAssignmentToInitialize.Categories.InitializeNextPageRequest(
                            this.Client,
                            nextPageLinkString);
                    }
                }

                if (educationAssignmentToInitialize.Resources != null && educationAssignmentToInitialize.Resources.CurrentPage != null)
                {
                    educationAssignmentToInitialize.Resources.AdditionalData = educationAssignmentToInitialize.AdditionalData;

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

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

                if (educationAssignmentToInitialize.Submissions != null && educationAssignmentToInitialize.Submissions.CurrentPage != null)
                {
                    educationAssignmentToInitialize.Submissions.AdditionalData = educationAssignmentToInitialize.AdditionalData;

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

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