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