コード例 #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));
        }
コード例 #2
0
ファイル: DatabaseApi.cs プロジェクト: artikh/CouchDude
		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);
		}