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)); }
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); }