Exemplo n.º 1
0
        public async Task <ResourceResponse <Document> > LoadNoReplace(
            IAmDocument doc)
        {
            ResourceResponse <Document> r;

            try
            {
                r = await client.ReadDocumentAsync(
                    UriFactory.CreateDocumentUri(
                        databaseId,
                        collectionId,
                        doc.Id),
                    new RequestOptions {
                    PartitionKey = new PartitionKey(doc.PartitionKey)
                });
            }
            catch (DocumentClientException de)
            {
                if (de.StatusCode == HttpStatusCode.NotFound)
                {
                    r = await client.CreateDocumentAsync(
                        UriFactory.CreateDocumentCollectionUri(
                            databaseId,
                            collectionId),
                        doc);
                }
                else
                {
                    throw;
                }
            }

            return(r);
        }
Exemplo n.º 2
0
        public async Task <ResourceResponse <Document> > LoadReplace(
            IAmDocument doc)
        {
            var r = await this.client.ReplaceDocumentAsync(
                UriFactory.CreateDocumentUri(
                    databaseId,
                    collectionId,
                    doc.Id),
                doc);

            return(r);
        }