public async Task <KvMetadata> AddOrUpdateAsync <T>(string key,
                                                            T item,
                                                            string reference = null)
        {
            Guard.ArgumentNotNullOrEmpty("key", key);
            Guard.ArgumentNotNull("item", item);

            HttpUrlBuilder uri = new HttpUrlBuilder(host)
                                 .AppendPath(CollectionName)
                                 .AppendPath(key);

            var response = await restClient.SendIfMatchAsync(uri, HttpMethod.Put, item, reference);

            return(KvMetadata.Make(CollectionName, response));
        }
Esempio n. 2
0
        public async Task <KvMetadata> LinkAsync <T>(GraphNode fromNode, string kind, GraphNode toNode, T properties, string reference = null)
        {
            Guard.ArgumentNotNull("fromNode", fromNode);
            Guard.ArgumentNotNullOrEmpty("kind", kind);
            Guard.ArgumentNotNull("toNode", toNode);

            HttpUrlBuilder uri = new HttpUrlBuilder(application.HostUrl)
                                 .AppendPath(fromNode.CollectionName)
                                 .AppendPath(fromNode.Key)
                                 .AppendPath("relation")
                                 .AppendPath(kind)
                                 .AppendPath(toNode.CollectionName)
                                 .AppendPath(toNode.Key);

            var response = await restClient.SendIfMatchAsync(uri, HttpMethod.Put, properties, reference);

            return(KvMetadata.Make(fromNode.CollectionName, response));
        }