public async Task DeleteDocumentAsync(string id) { var doc = await _documentRepo.GetDocumentByIdAsync(id); string storagePath = Path.Combine(_pProvider.ContentPath(), doc.OwnerId); if (doc.IsFile) { _pProvider.DeleteFile(Path.Combine(storagePath, doc.DocumentId)); await _documentRepo.DeleteDocumentAsync(doc.DocumentId); } else { var to_delete = await _documentRepo.GetAllUserDocumentsAsync(doc.OwnerId); foreach (var document in to_delete) { if (document.Path.Contains(doc.Path)) { if (document.IsFile) { _pProvider.DeleteFile(Path.Combine(storagePath, document.DocumentId)); } await _documentRepo.DeleteDocumentAsync(document.DocumentId); } } await _documentRepo.DeleteDocumentAsync(doc.DocumentId); } }