コード例 #1
0
ファイル: Program.cs プロジェクト: blaskoa/library
        private static int RunFindByISBNAndReturnExitCode(FindByISBNOptions options, LibraryService service)
        {
            var printMedium = service.FindMediumWithIsbn(options.ISBN);

            if (printMedium != null)
            {
                Console.WriteLine(printMedium);
            }
            else
            {
                Console.WriteLine($"Cannot find print media with ISBN {options.ISBN}");
            }

            return(0);
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: blaskoa/library
        public static int Main(string[] args)
        {
            IBookRepository     bookRepository     = new BookCsvRepository(Path.Combine(DataFolder, BooksFilePath));
            IAuthorRepository   authorRepository   = new AuthorCsvRepository(Path.Combine(DataFolder, AuthorsFilePath));
            IMagazineRepository magazineRepository = new MagazineCsvRepository(Path.Combine(DataFolder, MagazinesFilePath));

            LibraryService service = new LibraryService(bookRepository, authorRepository, magazineRepository);

            return(Parser.Default.ParseArguments <GetAllOptions, FindByAuthorOptions, FindByISBNOptions>(args)
                   .MapResult(
                       (GetAllOptions opts) => RunGetAndReturnExitCode(opts, service),
                       (FindByAuthorOptions opts) => RunFindByAuthorAndReturnExitCode(opts, service),
                       (FindByISBNOptions opts) => RunFindByISBNAndReturnExitCode(opts, service),
                       errs => 1));
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: blaskoa/library
        private static int RunGetAndReturnExitCode(GetAllOptions options, LibraryService service)
        {
            IQueryable <PrintMedium> printMedia;

            if (options.Sorted)
            {
                printMedia = service.GetAllPrintMediaSorted();
            }
            else
            {
                printMedia = service.GetAllPrintMedia();
            }

            var allPrintMediaString = string.Join(Environment.NewLine, printMedia);

            Console.WriteLine(allPrintMediaString);
            return(0);
        }
コード例 #4
0
        public MainMenu()
        {
            var repository = new LibraryRepository();

            _service = new LibraryService(repository);
        }
コード例 #5
0
ファイル: Program.cs プロジェクト: blaskoa/library
        private static int RunFindByAuthorAndReturnExitCode(FindByAuthorOptions options, LibraryService service)
        {
            var    printMediaByAuthor = service.GetPrintMediaByAuthor(options.Email);
            string printMediaByAuthorString;

            if (printMediaByAuthor.Any())
            {
                printMediaByAuthorString = string.Join(Environment.NewLine, printMediaByAuthor);
            }
            else
            {
                printMediaByAuthorString = $"Author {options.Email} has no print media";
            }

            Console.WriteLine(printMediaByAuthorString);
            return(0);
        }