コード例 #1
0
        async Task <DocumentInfo> CopyDocumentInternal(
            string originalDocumentId, string originalDocumentRevision, string targetDocumentId,
            string targetDocumentRevision)
        {
            var fullOriginalDocumentUri = uriConstructor.GetFullDocumentUri(
                originalDocumentId, originalDocumentRevision);
            var request = new HttpRequestMessage(CopyHttpMethod, fullOriginalDocumentUri);
            var targetDocumentUriString = uriConstructor.GetDocumentUriString(
                targetDocumentId, targetDocumentRevision);

            request.Headers.TryAddWithoutValidation("Destination", targetDocumentUriString);

            var response = await parent.RequestCouchDb(request);

            if (!response.IsSuccessStatusCode)
            {
                var couchApiError = new CouchError(parent.Settings.Serializer, response);
                couchApiError.ThrowDatabaseMissingExceptionIfNedded(uriConstructor);
                couchApiError.ThrowStaleStateExceptionForDocumentCopyIfNedded(
                    originalDocumentId, originalDocumentRevision, targetDocumentId, targetDocumentRevision);
                couchApiError.ThrowCouchCommunicationException();
            }
            return(await ReadDocumentInfo(response));
        }
コード例 #2
0
ファイル: DatabaseApi.cs プロジェクト: artikh/CouchDude
		async Task<DocumentInfo> CopyDocumentInternal(
			string originalDocumentId, string originalDocumentRevision, string targetDocumentId,
			string targetDocumentRevision)
		{
			var fullOriginalDocumentUri = uriConstructor.GetFullDocumentUri(
				originalDocumentId, originalDocumentRevision);
			var request = new HttpRequestMessage(CopyHttpMethod, fullOriginalDocumentUri);
			var targetDocumentUriString = uriConstructor.GetDocumentUriString(
				targetDocumentId, targetDocumentRevision);
			request.Headers.TryAddWithoutValidation("Destination", targetDocumentUriString);

			var response = await parent.RequestCouchDb(request);

			if (!response.IsSuccessStatusCode)
			{
				var couchApiError = new CouchError(parent.Settings.Serializer, response);
				couchApiError.ThrowDatabaseMissingExceptionIfNedded(uriConstructor);
				couchApiError.ThrowStaleStateExceptionForDocumentCopyIfNedded(
					originalDocumentId, originalDocumentRevision, targetDocumentId, targetDocumentRevision);
				couchApiError.ThrowCouchCommunicationException();
			}
			return await ReadDocumentInfo(response);
		}