Example #1
0
        internal void ShowAllBooks()
        {
            LibraryRepository repository = new LibraryRepository();
            var booksList = repository.GetBooksList();

            foreach (var book in booksList)
            {
                Console.WriteLine($" {book.Id} \t{book.Title}   \t{book.Year} \t{book.Author}");
            }
            Console.WriteLine();
        }
Example #2
0
        internal void DeleteBook()
        {
            Console.WriteLine("Deleting a Book...");
            Console.WriteLine();
            Console.Write("Enter Book's ID: ");
            int id = int.Parse(Console.ReadLine());

            Console.WriteLine();
            LibraryRepository repository = new LibraryRepository();

            repository.DeleteBook(id);
            Console.WriteLine($"Book No. {id} is deleted.");
            Console.WriteLine();
        }
Example #3
0
        internal void SearchByGenre()
        {
            Console.WriteLine();
            Console.Write("Enter Genre: ");
            string genre = Console.ReadLine();

            Console.WriteLine();
            LibraryRepository repository = new LibraryRepository();
            var booksByGenre             = repository.GetBooksListByGenre(genre);

            foreach (var book in booksByGenre)
            {
                Console.WriteLine($" {book.Id} \t{book.Title}   \t{book.Year} \t{book.Author}");
            }
            Console.WriteLine();
        }
Example #4
0
        internal void SearchByYear()
        {
            Console.WriteLine();
            Console.Write("Enter Year: ");
            int year = int.Parse(Console.ReadLine());

            Console.WriteLine();
            LibraryRepository repository = new LibraryRepository();
            var booksByYear = repository.GetBooksListByYear(year);

            foreach (var book in booksByYear)
            {
                Console.WriteLine($" {book.Id} \t{book.Title}   \t{book.Year} \t{book.Author}");;
            }
            Console.WriteLine();
        }
Example #5
0
        internal void AddBook()
        {
            Book book = new Book();

            Console.WriteLine("Adding New Book...");
            Console.WriteLine();
            Console.Write("Enter Book's Title: ");
            book.Title = Console.ReadLine();
            Console.Write("Enter Book's Author: ");
            book.Author = Console.ReadLine();
            Console.Write("Enter Book's Genre: ");
            book.Genre = Console.ReadLine();
            Console.Write("Enter Book's Year: ");
            book.Year          = int.Parse(Console.ReadLine());
            book.InInventory   = true;
            book.BorrowedTimes = 0;
            LibraryRepository repository = new LibraryRepository();

            repository.AddBook(book);
            Console.WriteLine("Book added.");
            Console.WriteLine();
        }