/// <summary> /// Updates the specified EducationUser using PATCH. /// </summary> /// <param name="educationUserToUpdate">The EducationUser 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 EducationUser.</returns> public async System.Threading.Tasks.Task <EducationUser> UpdateAsync(EducationUser educationUserToUpdate, CancellationToken cancellationToken) { if (educationUserToUpdate.AdditionalData != null) { if (educationUserToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.ResponseHeaders) || educationUserToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.StatusCode)) { throw new ClientException( new Error { Code = GeneratedErrorConstants.Codes.NotAllowed, Message = String.Format(GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, educationUserToUpdate.GetType().Name) }); } } if (educationUserToUpdate.AdditionalData != null) { if (educationUserToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.ResponseHeaders) || educationUserToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.StatusCode)) { throw new ClientException( new Error { Code = GeneratedErrorConstants.Codes.NotAllowed, Message = String.Format(GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, educationUserToUpdate.GetType().Name) }); } } this.ContentType = "application/json"; this.Method = "PATCH"; var updatedEntity = await this.SendAsync <EducationUser>(educationUserToUpdate, cancellationToken).ConfigureAwait(false); this.InitializeCollectionProperties(updatedEntity); return(updatedEntity); }
/// <summary> /// Updates the specified EducationUser using PATCH. /// </summary> /// <param name="educationUserToUpdate">The EducationUser to update.</param> /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param> /// <returns>The updated EducationUser.</returns> public async System.Threading.Tasks.Task <EducationUser> UpdateAsync(EducationUser educationUserToUpdate, CancellationToken cancellationToken) { this.ContentType = "application/json"; this.Method = "PATCH"; var updatedEntity = await this.SendAsync <EducationUser>(educationUserToUpdate, cancellationToken).ConfigureAwait(false); return(updatedEntity); }
/// <summary> /// Creates the specified EducationUser using POST. /// </summary> /// <param name="educationUserToCreate">The EducationUser to create.</param> /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param> /// <returns>The created EducationUser.</returns> public async System.Threading.Tasks.Task <EducationUser> CreateAsync(EducationUser educationUserToCreate, CancellationToken cancellationToken) { this.ContentType = "application/json"; this.Method = "POST"; var newEntity = await this.SendAsync <EducationUser>(educationUserToCreate, cancellationToken).ConfigureAwait(false); this.InitializeCollectionProperties(newEntity); return(newEntity); }
/// <summary> /// Initializes any collection properties after deserialization, like next requests for paging. /// </summary> /// <param name="educationUserToInitialize">The <see cref="EducationUser"/> with the collection properties to initialize.</param> private void InitializeCollectionProperties(EducationUser educationUserToInitialize) { if (educationUserToInitialize != null && educationUserToInitialize.AdditionalData != null) { if (educationUserToInitialize.Classes != null && educationUserToInitialize.Classes.CurrentPage != null) { educationUserToInitialize.Classes.AdditionalData = educationUserToInitialize.AdditionalData; object nextPageLink; educationUserToInitialize.AdditionalData.TryGetValue("*****@*****.**", out nextPageLink); var nextPageLinkString = nextPageLink as string; if (!string.IsNullOrEmpty(nextPageLinkString)) { educationUserToInitialize.Classes.InitializeNextPageRequest( this.Client, nextPageLinkString); } } if (educationUserToInitialize.Schools != null && educationUserToInitialize.Schools.CurrentPage != null) { educationUserToInitialize.Schools.AdditionalData = educationUserToInitialize.AdditionalData; object nextPageLink; educationUserToInitialize.AdditionalData.TryGetValue("*****@*****.**", out nextPageLink); var nextPageLinkString = nextPageLink as string; if (!string.IsNullOrEmpty(nextPageLinkString)) { educationUserToInitialize.Schools.InitializeNextPageRequest( this.Client, nextPageLinkString); } } if (educationUserToInitialize.TaughtClasses != null && educationUserToInitialize.TaughtClasses.CurrentPage != null) { educationUserToInitialize.TaughtClasses.AdditionalData = educationUserToInitialize.AdditionalData; object nextPageLink; educationUserToInitialize.AdditionalData.TryGetValue("*****@*****.**", out nextPageLink); var nextPageLinkString = nextPageLink as string; if (!string.IsNullOrEmpty(nextPageLinkString)) { educationUserToInitialize.TaughtClasses.InitializeNextPageRequest( this.Client, nextPageLinkString); } } } }
/// <summary> /// Adds the specified EducationUser to the collection via POST. /// </summary> /// <param name="educationUser">The EducationUser 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(EducationUser educationUser, CancellationToken cancellationToken) { this.ContentType = "application/json"; this.Method = "POST"; if (string.IsNullOrEmpty(educationUser.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/users/{1}", this.Client.BaseUrl, educationUser.Id) }; return(this.SendAsync(requestBody, cancellationToken)); }
/// <summary> /// Adds the specified EducationUser to the collection via POST. /// </summary> /// <param name="educationUser">The EducationUser to add.</param> /// <returns>The task to await.</returns> public System.Threading.Tasks.Task AddAsync(EducationUser educationUser) { return(this.AddAsync(educationUser, CancellationToken.None)); }
/// <summary> /// Updates the specified EducationUser using PATCH. /// </summary> /// <param name="educationUserToUpdate">The EducationUser to update.</param> /// <returns>The updated EducationUser.</returns> public System.Threading.Tasks.Task <EducationUser> UpdateAsync(EducationUser educationUserToUpdate) { return(this.UpdateAsync(educationUserToUpdate, CancellationToken.None)); }
/// <summary> /// Adds the specified EducationUser to the collection via POST. /// </summary> /// <param name="educationUser">The EducationUser to add.</param> /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param> /// <returns>The created EducationUser.</returns> public System.Threading.Tasks.Task <EducationUser> AddAsync(EducationUser educationUser, CancellationToken cancellationToken) { this.ContentType = "application/json"; this.Method = "POST"; return(this.SendAsync <EducationUser>(educationUser, cancellationToken)); }