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