示例#1
0
        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);
            }
        }