예제 #1
0
        public void LazyLoad()
        {
            _screenHelper.Reset();
            var sw = new Stopwatch();

            _screenHelper.PrintLazyLoading();
            using (var context = new DataContext())
            {
                sw.Start();
                var books = context.Books.ToList <Book>();

                foreach (var book in books)
                {
                    if (book.Reader?.Address?.Street != null)
                    {
                        Console.WriteLine(book.Reader.Address.Street);
                    }
                }

                sw.Stop();
            }

            _screenHelper.PrintElapsedTime(sw.Elapsed);

            _menuHelper.NavigateToMainMenu();
        }
예제 #2
0
        public void ListAllBooks()
        {
            _screenHelper.Reset();
            _screenHelper.PrintBookListingText();

            var books = _bookrepository.GetAllBooks();

            ListBooks(books);

            _menuHelper.NavigateToMainMenu();
        }
예제 #3
0
        public void GenerateData(int amount, IBorrow borrow)
        {
            GenerateBooks(amount);
            GenerateReaders(amount, borrow);

            _screenHelper.Reset();
            _screenHelper.PrintSuccessfulSeeding();
            _menuHelper.NavigateToMainMenu();
        }
예제 #4
0
파일: Add.cs 프로젝트: kuzditomi/codingDojo
        public void AddNewBook()
        {
            _screenHelper.Reset();
            var book = _screenHelper.GetNewBookDetails();

            _bookrepository.StoreABook(book);
            _screenHelper.PrintBookAddedMessage(book);
            _menuHelper.NavigateToMainMenu();
        }
예제 #5
0
        public void ReturnBook()
        {
            _screenHelper.Reset();
            var id   = _screenHelper.GetBookId();
            var book = _bookRepository.ReturnABook(id);

            if (book == null)
            {
                Console.WriteLine(Texts.NoBook);
            }
            _menuHelper.NavigateToMainMenu();
        }
예제 #6
0
        private void SearchBy(string property, Func <Book, string, bool> expression)
        {
            _screenHelper.Reset();
            var input = _screenHelper.ReadInputString(property);

            var books  = _bookRepository.GetAllBooks();
            var result = books.Where(b => expression(b, input)).ToList();

            _screenHelper.PrintSearchResult(result);

            _menuHelper.NavigateToMainMenu();
        }
예제 #7
0
        public void PerformBorrowingProcess()
        {
            _screenHelper.Reset();
            var id           = _screenHelper.GetBookId();
            var reader       = _screenHelper.GetNewReader();
            var daysToBorrow = _screenHelper.GetBorrowDays();

            var book = BorrowSingleBook(id, reader, daysToBorrow);

            _screenHelper.PrintBookBorrowedMessage(book, reader);

            _menuHelper.NavigateToMainMenu();
        }