/// <summary>
        /// Updates the data of the specific edge based on its document ID.
        /// </summary>
        /// <typeparam name="T">Type of the patch object used to perform a partial update of the edge document.</typeparam>
        /// <typeparam name="U">Type of the returned edge document,
        /// when <see cref="PatchEdgeQuery.ReturnOld"/> or <see cref="PatchEdgeQuery.ReturnNew"/> query params are used.</typeparam>
        /// <param name="graphName">The name of the graph in which to update the edge.</param>
        /// <param name="documentId">The document ID of the edge to update.</param>
        /// <param name="edge"></param>
        /// <param name="query"></param>
        /// <returns></returns>
        public virtual async Task <PatchEdgeResponse <U> > PatchEdgeAsync <T, U>(
            string graphName,
            string documentId,
            T edge,
            PatchEdgeQuery query = null)
        {
            ValidateDocumentId(documentId);

            string uri = _graphApiPath + "/" + WebUtility.UrlEncode(graphName) +
                         "/edge/" + documentId;

            if (query != null)
            {
                uri += "?" + query.ToQueryString();
            }

            var content = GetContent(edge, new ApiClientSerializationOptions(true, true));

            using (var response = await _transport.PatchAsync(uri, content))
            {
                if (response.IsSuccessStatusCode)
                {
                    var stream = await response.Content.ReadAsStreamAsync();

                    return(DeserializeJsonFromStream <PatchEdgeResponse <U> >(stream));
                }
                throw await GetApiErrorException(response);
            }
        }
        /// <summary>
        /// Updates the data of the specific edge in the collection.
        /// PATCH/_api/gharial/{graph}/edge/{collection}/{edge}
        /// </summary>
        /// <typeparam name="T">Type of the returned edge document, when ReturnOld or ReturnNew query params are used.</typeparam>
        /// <typeparam name="U">Type of the patch object used to perform a partial update of the edge document.</typeparam>
        /// <param name="graphName"></param>
        /// <param name="collectionName"></param>
        /// <param name="edgeKey"></param>
        /// <param name="edge"></param>
        /// <param name="query"></param>
        /// <returns></returns>
        public async Task <PatchEdgeResponse <T> > PatchEdgeAsync <T, U>(
            string graphName,
            string collectionName,
            string edgeKey,
            U edge,
            PatchEdgeQuery query = null)
        {
            var content = GetContent(edge, true, true);

            string uri = _graphApiPath + "/" + WebUtility.UrlEncode(graphName) +
                         "/edge/" + WebUtility.UrlEncode(collectionName) + "/" + WebUtility.UrlEncode(edgeKey);

            if (query != null)
            {
                uri += "?" + query.ToQueryString();
            }

            using (var response = await _transport.PatchAsync(uri, content))
            {
                if (response.IsSuccessStatusCode)
                {
                    var stream = await response.Content.ReadAsStreamAsync();

                    return(DeserializeJsonFromStream <PatchEdgeResponse <T> >(stream));
                }
                throw await GetApiErrorException(response);
            }
        }
Exemple #3
0
 /// <summary>
 /// Updates the data of the specific edge in the collection.
 /// PATCH/_api/gharial/{graph}/edge/{collection}/{edge}
 /// </summary>
 /// <typeparam name="TPatch">Type of the returned edge document, when ReturnOld or ReturnNew query params are used.</typeparam>
 /// <typeparam name="TReturned">Type of the patch object used to perform a partial update of the edge document.</typeparam>
 /// <param name="graphName"></param>
 /// <param name="collectionName"></param>
 /// <param name="edgeKey"></param>
 /// <param name="edge"></param>
 /// <param name="query"></param>
 /// <returns></returns>
 public virtual async Task <PatchEdgeResponse <TReturned> > PatchEdgeAsync <TPatch, TReturned>(
     string graphName,
     string collectionName,
     string edgeKey,
     TPatch edge,
     PatchEdgeQuery query = null,
     CancellationToken cancellationToken = default)
 {
     return(await PatchRequestAsync(
                $"{ApiRootPath}/{WebUtility.UrlEncode(graphName)}/edge/{WebUtility.UrlEncode(collectionName)}/{WebUtility.UrlEncode(edgeKey)}",
                response => new PatchEdgeResponse <TReturned>(response), edge, query, cancellationToken));
 }
 /// <summary>
 /// Updates the data of the specific edge in the collection.
 /// PATCH/_api/gharial/{graph}/edge/{collection}/{edge}
 /// </summary>
 /// <typeparam name="T">Type of the patch object used to perform a partial update of the edge document.</typeparam>
 /// <typeparam name="U">Type of the returned edge document,
 /// when <see cref="PatchEdgeQuery.ReturnOld"/> or <see cref="PatchEdgeQuery.ReturnNew"/> query params are used.</typeparam>
 /// <param name="graphName">The name of the graph in which to update the edge.</param>
 /// <param name="collectionName">The name of the edge collection.</param>
 /// <param name="edgeKey">The document key of the edge to update.</param>
 /// <param name="edge"></param>
 /// <param name="query"></param>
 /// <returns></returns>
 public virtual Task <PatchEdgeResponse <U> > PatchEdgeAsync <T, U>(
     string graphName,
     string collectionName,
     string edgeKey,
     T edge,
     PatchEdgeQuery query = null)
 {
     return(PatchEdgeAsync <T, U>(
                graphName,
                WebUtility.UrlEncode(collectionName) + "/" + WebUtility.UrlEncode(edgeKey),
                edge,
                query));
 }