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