public async Task RemoveFileFromDocument(Guid documentId) { using (var unitOfWork = await DataConnectionFactory.CreateUnitOfWork()) { var file = await unitOfWork.Files.GetByDocumentId(documentId); if (file == null) { throw new LogicException("No file is attached to this document."); } _fileProvider.DeleteFile(file.FileId); await unitOfWork.Files.Delete(file.Id); await unitOfWork.SaveChangesAsync(); } }