Пример #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
        private void PrintMainMenu()
        {
            _screenHelper.Reset();
            Console.WriteLine("Choose a number from the library options:\r\n");

            Console.WriteLine("0 - Add book");
            Console.WriteLine("1 - Search book");
            Console.WriteLine("2 - Borrow book");
            Console.WriteLine("3 - Return book");
            Console.WriteLine("4 - List all books");
            Console.WriteLine("5 - List expired books");
            Console.WriteLine("6 - Seed data");
            Console.WriteLine("7 - LazyLoad");
            Console.WriteLine("8 - EagerLoad");
            Console.WriteLine("9 - Exit");
        }
Пример #4
0
        public void GenerateData(int amount, IBorrow borrow)
        {
            GenerateBooks(amount);
            GenerateReaders(amount, borrow);

            _screenHelper.Reset();
            _screenHelper.PrintSuccessfulSeeding();
            _menuHelper.NavigateToMainMenu();
        }
Пример #5
0
        public void AddNewBook()
        {
            _screenHelper.Reset();
            var book = _screenHelper.GetNewBookDetails();

            _bookrepository.StoreABook(book);
            _screenHelper.PrintBookAddedMessage(book);
            _menuHelper.NavigateToMainMenu();
        }
Пример #6
0
        public void ReturnBook()
        {
            _screenHelper.Reset();
            var id   = _screenHelper.GetBookId();
            var book = _bookRepository.ReturnABook(id);

            if (book == null)
            {
                Console.WriteLine(Texts.NoBook);
            }
            _menuHelper.NavigateToMainMenu();
        }
Пример #7
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();
        }
Пример #8
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();
        }