Exemple #1
0
        async Task <DocumentInfo> DeleteAttachmentInternal(string attachmentId, string documentId, string documentRevision)
        {
            var attachmentUri  = uriConstructor.GetFullAttachmentUri(attachmentId, documentId, documentRevision);
            var requestMessage = new HttpRequestMessage(HttpMethod.Delete, attachmentUri);
            var response       = await parent.RequestCouchDb(requestMessage);

            if (!response.IsSuccessStatusCode)
            {
                var error = new CouchError(parent.Settings.Serializer, response);
                error.ThrowDatabaseMissingExceptionIfNedded(uriConstructor.DatabaseName);
                error.ThrowAttachmentMissingException(attachmentId, documentId, documentRevision);
                error.ThrowDocumentNotFoundIfNedded(documentId, documentRevision);
                error.ThrowStaleStateExceptionIfNedded(
                    string.Format("deleting attachment ID '{0}'", attachmentId), documentId, documentRevision);
                error.ThrowCouchCommunicationException();
            }
            return(await ReadDocumentInfo(response));
        }
Exemple #2
0
		async Task<DocumentInfo> DeleteAttachmentInternal(string attachmentId, string documentId, string documentRevision)
		{
			var attachmentUri = uriConstructor.GetFullAttachmentUri(attachmentId, documentId, documentRevision);
			var requestMessage = new HttpRequestMessage(HttpMethod.Delete, attachmentUri);
			var response = await parent.RequestCouchDb(requestMessage);
			if (!response.IsSuccessStatusCode)
			{
				var error = new CouchError(parent.Settings.Serializer, response);
				error.ThrowDatabaseMissingExceptionIfNedded(uriConstructor.DatabaseName);
				error.ThrowAttachmentMissingException(attachmentId, documentId, documentRevision);
				error.ThrowDocumentNotFoundIfNedded(documentId, documentRevision);
				error.ThrowStaleStateExceptionIfNedded(
					string.Format("deleting attachment ID '{0}'", attachmentId), documentId, documentRevision);
				error.ThrowCouchCommunicationException();
			}
			return await ReadDocumentInfo(response);
		}