public void SaveLibraryCatalog(LibraryCatalog catalog, IOutputPort outputPort) { // Persist to database _repository.Insert(catalog); outputPort.HandleMessage($"\nPrepared saving CatalogLibrary ({catalog.Directories.Count} directories, {catalog.Photos.Count} photos)"); // Catch exception thrown by EF Core var exception = _repository.TrySave(); var message = "Saved LibraryCatalog"; if (exception != null) { outputPort.HandleException(exception, message); } else { outputPort.HandleMessage(message); } }
public LibraryCatalog CreateLibraryCatalog(string computerName, string directoryPath, IOutputPort outputPort) { // Find all photos. Does not read metadata. var(photosRead, readErrors) = _photoDirectoryCrawler.FindPhotos( directoryPath, outputPort, true); outputPort.HandleMessage($"\n{photosRead.Count} photos in source directory ({readErrors.Count} errors)"); // TBD: Handle read errors? // Create catalog index with metadata var catalog = new LibraryCatalog(computerName, directoryPath, photosRead); catalog.Init(); return(catalog); }