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