Пример #1
0
        /// <summary>
        /// Updates the specified DocumentComment using PATCH.
        /// </summary>
        /// <param name="documentCommentToUpdate">The DocumentComment 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 DocumentComment.</returns>
        public async System.Threading.Tasks.Task <DocumentComment> UpdateAsync(DocumentComment documentCommentToUpdate, CancellationToken cancellationToken)
        {
            if (documentCommentToUpdate.AdditionalData != null)
            {
                if (documentCommentToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.ResponseHeaders) ||
                    documentCommentToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.StatusCode))
                {
                    throw new ClientException(
                              new Error
                    {
                        Code    = GeneratedErrorConstants.Codes.NotAllowed,
                        Message = String.Format(GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, documentCommentToUpdate.GetType().Name)
                    });
                }
            }
            if (documentCommentToUpdate.AdditionalData != null)
            {
                if (documentCommentToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.ResponseHeaders) ||
                    documentCommentToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.StatusCode))
                {
                    throw new ClientException(
                              new Error
                    {
                        Code    = GeneratedErrorConstants.Codes.NotAllowed,
                        Message = String.Format(GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, documentCommentToUpdate.GetType().Name)
                    });
                }
            }
            this.ContentType = "application/json";
            this.Method      = "PATCH";
            var updatedEntity = await this.SendAsync <DocumentComment>(documentCommentToUpdate, cancellationToken).ConfigureAwait(false);

            this.InitializeCollectionProperties(updatedEntity);
            return(updatedEntity);
        }
Пример #2
0
        /// <summary>
        /// Creates the specified DocumentComment using POST.
        /// </summary>
        /// <param name="documentCommentToCreate">The DocumentComment to create.</param>
        /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
        /// <returns>The created DocumentComment.</returns>
        public async System.Threading.Tasks.Task <DocumentComment> CreateAsync(DocumentComment documentCommentToCreate, CancellationToken cancellationToken)
        {
            this.ContentType = "application/json";
            this.Method      = "POST";
            var newEntity = await this.SendAsync <DocumentComment>(documentCommentToCreate, cancellationToken).ConfigureAwait(false);

            this.InitializeCollectionProperties(newEntity);
            return(newEntity);
        }
Пример #3
0
        /// <summary>
        /// Initializes any collection properties after deserialization, like next requests for paging.
        /// </summary>
        /// <param name="documentCommentToInitialize">The <see cref="DocumentComment"/> with the collection properties to initialize.</param>
        private void InitializeCollectionProperties(DocumentComment documentCommentToInitialize)
        {
            if (documentCommentToInitialize != null && documentCommentToInitialize.AdditionalData != null)
            {
                if (documentCommentToInitialize.Replies != null && documentCommentToInitialize.Replies.CurrentPage != null)
                {
                    documentCommentToInitialize.Replies.AdditionalData = documentCommentToInitialize.AdditionalData;

                    object nextPageLink;
                    documentCommentToInitialize.AdditionalData.TryGetValue("*****@*****.**", out nextPageLink);
                    var nextPageLinkString = nextPageLink as string;

                    if (!string.IsNullOrEmpty(nextPageLinkString))
                    {
                        documentCommentToInitialize.Replies.InitializeNextPageRequest(
                            this.Client,
                            nextPageLinkString);
                    }
                }
            }
        }
Пример #4
0
 /// <summary>
 /// Creates the specified DocumentComment using POST.
 /// </summary>
 /// <param name="documentCommentToCreate">The DocumentComment to create.</param>
 /// <returns>The created DocumentComment.</returns>
 public System.Threading.Tasks.Task <DocumentComment> CreateAsync(DocumentComment documentCommentToCreate)
 {
     return(this.CreateAsync(documentCommentToCreate, CancellationToken.None));
 }
 /// <summary>
 /// Adds the specified DocumentComment to the collection via POST.
 /// </summary>
 /// <param name="documentComment">The DocumentComment to add.</param>
 /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
 /// <returns>The created DocumentComment.</returns>
 public System.Threading.Tasks.Task <DocumentComment> AddAsync(DocumentComment documentComment, CancellationToken cancellationToken)
 {
     this.ContentType = "application/json";
     this.Method      = "POST";
     return(this.SendAsync <DocumentComment>(documentComment, cancellationToken));
 }
 /// <summary>
 /// Adds the specified DocumentComment to the collection via POST.
 /// </summary>
 /// <param name="documentComment">The DocumentComment to add.</param>
 /// <returns>The created DocumentComment.</returns>
 public System.Threading.Tasks.Task <DocumentComment> AddAsync(DocumentComment documentComment)
 {
     return(this.AddAsync(documentComment, CancellationToken.None));
 }