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