public void RemoveDocument(DocumentKey documentKey) { var metadata = DocumentMetadataRepository.GetDocumentMetadata(documentKey); using (var scope = new DMSTransactionScope()) { Parallel.ForEach(metadata.References, refKey => BinaryDocumentRepository.RemoveDocument(refKey)); DocumentMetadataRepository.RemoveDocumentMetadata(documentKey); scope.Complete(); } }
public void AddDocument(TDocument document) { if (DocumentMetadataRepository.DocumentExist(document.Key)) { throw new DMSException("Document with such an ID already exists."); } var metadata = document.GetMetadata(); var binaries = document.GetBinaries(); using (var scope = new DMSTransactionScope()) { Parallel.ForEach(binaries, binary => BinaryDocumentRepository.AddDocument(binary.Key, binary.Value)); DocumentMetadataRepository.AddDocumentMetadata(metadata); scope.Complete(); } }