/// <summary> /// Updates the specified Custodian using PATCH. /// </summary> /// <param name="custodianToUpdate">The Custodian to update.</param> /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param> /// <exception cref="Microsoft.Graph.ClientException">Thrown when an object returned in a response is used for updating an object in Microsoft Graph.</exception> /// <returns>The updated Custodian.</returns> public async System.Threading.Tasks.Task <Custodian> UpdateAsync(Custodian custodianToUpdate, CancellationToken cancellationToken) { if (custodianToUpdate.AdditionalData != null) { if (custodianToUpdate.AdditionalData.ContainsKey(Microsoft.Graph.Constants.HttpPropertyNames.ResponseHeaders) || custodianToUpdate.AdditionalData.ContainsKey(Microsoft.Graph.Constants.HttpPropertyNames.StatusCode)) { throw new Microsoft.Graph.ClientException( new Microsoft.Graph.Error { Code = Microsoft.Graph.GeneratedErrorConstants.Codes.NotAllowed, Message = String.Format(Microsoft.Graph.GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, custodianToUpdate.GetType().Name) }); } } if (custodianToUpdate.AdditionalData != null) { if (custodianToUpdate.AdditionalData.ContainsKey(Microsoft.Graph.Constants.HttpPropertyNames.ResponseHeaders) || custodianToUpdate.AdditionalData.ContainsKey(Microsoft.Graph.Constants.HttpPropertyNames.StatusCode)) { throw new Microsoft.Graph.ClientException( new Microsoft.Graph.Error { Code = Microsoft.Graph.GeneratedErrorConstants.Codes.NotAllowed, Message = String.Format(Microsoft.Graph.GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, custodianToUpdate.GetType().Name) }); } } this.ContentType = "application/json"; this.Method = "PATCH"; var updatedEntity = await this.SendAsync <Custodian>(custodianToUpdate, cancellationToken).ConfigureAwait(false); this.InitializeCollectionProperties(updatedEntity); return(updatedEntity); }
/// <summary> /// Creates the specified Custodian using POST. /// </summary> /// <param name="custodianToCreate">The Custodian to create.</param> /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param> /// <returns>The created Custodian.</returns> public async System.Threading.Tasks.Task <Custodian> CreateAsync(Custodian custodianToCreate, CancellationToken cancellationToken) { this.ContentType = "application/json"; this.Method = "POST"; var newEntity = await this.SendAsync <Custodian>(custodianToCreate, cancellationToken).ConfigureAwait(false); this.InitializeCollectionProperties(newEntity); return(newEntity); }
/// <summary> /// Initializes any collection properties after deserialization, like next requests for paging. /// </summary> /// <param name="custodianToInitialize">The <see cref="Custodian"/> with the collection properties to initialize.</param> private void InitializeCollectionProperties(Custodian custodianToInitialize) { if (custodianToInitialize != null && custodianToInitialize.AdditionalData != null) { if (custodianToInitialize.SiteSources != null && custodianToInitialize.SiteSources.CurrentPage != null) { custodianToInitialize.SiteSources.AdditionalData = custodianToInitialize.AdditionalData; object nextPageLink; custodianToInitialize.AdditionalData.TryGetValue("*****@*****.**", out nextPageLink); var nextPageLinkString = nextPageLink as string; if (!string.IsNullOrEmpty(nextPageLinkString)) { custodianToInitialize.SiteSources.InitializeNextPageRequest( this.Client, nextPageLinkString); } } if (custodianToInitialize.UnifiedGroupSources != null && custodianToInitialize.UnifiedGroupSources.CurrentPage != null) { custodianToInitialize.UnifiedGroupSources.AdditionalData = custodianToInitialize.AdditionalData; object nextPageLink; custodianToInitialize.AdditionalData.TryGetValue("*****@*****.**", out nextPageLink); var nextPageLinkString = nextPageLink as string; if (!string.IsNullOrEmpty(nextPageLinkString)) { custodianToInitialize.UnifiedGroupSources.InitializeNextPageRequest( this.Client, nextPageLinkString); } } if (custodianToInitialize.UserSources != null && custodianToInitialize.UserSources.CurrentPage != null) { custodianToInitialize.UserSources.AdditionalData = custodianToInitialize.AdditionalData; object nextPageLink; custodianToInitialize.AdditionalData.TryGetValue("*****@*****.**", out nextPageLink); var nextPageLinkString = nextPageLink as string; if (!string.IsNullOrEmpty(nextPageLinkString)) { custodianToInitialize.UserSources.InitializeNextPageRequest( this.Client, nextPageLinkString); } } } }
/// <summary> /// Creates the specified Custodian using POST. /// </summary> /// <param name="custodianToCreate">The Custodian to create.</param> /// <returns>The created Custodian.</returns> public System.Threading.Tasks.Task <Custodian> CreateAsync(Custodian custodianToCreate) { return(this.CreateAsync(custodianToCreate, CancellationToken.None)); }
/// <summary> /// Adds the specified Custodian to the collection via POST. /// </summary> /// <param name="custodian">The Custodian to add.</param> /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param> /// <returns>The created Custodian.</returns> public System.Threading.Tasks.Task <Custodian> AddAsync(Custodian custodian, CancellationToken cancellationToken) { this.ContentType = "application/json"; this.Method = "POST"; return(this.SendAsync <Custodian>(custodian, cancellationToken)); }
/// <summary> /// Adds the specified Custodian to the collection via POST. /// </summary> /// <param name="custodian">The Custodian to add.</param> /// <returns>The created Custodian.</returns> public System.Threading.Tasks.Task <Custodian> AddAsync(Custodian custodian) { return(this.AddAsync(custodian, CancellationToken.None)); }