Пример #1
0
 public Task <TResult> Execute(TQuery query)
 {
     try
     {
         return(InternalExecute(query));
     }
     catch (DocumentClientException ex)
     {
         throw DataAccessException.FromInnerException(ex);
     }
 }
Пример #2
0
        public async Task <string> Create(List list)
        {
            try
            {
                var uri    = UriFactory.CreateDocumentCollectionUri(db, collection);
                var result = await documentClient.CreateDocumentAsync(uri, list);

                return(result.Resource.Id);
            }
            catch (DocumentClientException ex)
            {
                throw DataAccessException.FromInnerException(ex);
            }
        }
Пример #3
0
        public Task Delete(string id)
        {
            try
            {
                var uri = UriFactory.CreateDocumentUri(db, collection, id);

                return(documentClient.DeleteDocumentAsync(uri, new RequestOptions
                {
                    PartitionKey = new PartitionKey(id)
                }));
            }
            catch (DocumentClientException ex)
            {
                if (ex.StatusCode == HttpStatusCode.NotFound)
                {
                    throw ResourceNotFoundException.FromResourceId(id);
                }

                throw DataAccessException.FromInnerException(ex);
            }
        }