Exemplo n.º 1
0
        /// <summary>
        /// Prints a list of all items
        /// </summary>
        private void ShowAllItems()
        {
            Console.Clear();
            Console.WriteLine("Showing items....");


            List <Book>  books  = BookRepository.GetBooks();
            List <Movie> movies = MovieRepository.GetMovies();

            Console.WriteLine("Title - Language - Year Of Publication - Pages - Author - Copies");

            foreach (Book book in books)
            {
                Console.WriteLine($"Book: {book.Title} {book.Language} {book.YearOfPublication} {book.Pages} {book.Author} {book.Copies}");
            }


            Console.WriteLine("\nTitle - Language - Year Of Publication - Genre - Type - Copies");
            foreach (Movie movie in movies)
            {
                Console.WriteLine($"Movie: {movie.Title} {movie.Language} {movie.YearOfPublication} {movie.Genre} {movie.Type} {movie.Copies}");
            }

            Console.WriteLine("press enter to continue");
            Console.ReadLine();
        }
Exemplo n.º 2
0
        /// <summary>
        /// list of books
        /// </summary>
        /// <returns>A list of books+</returns>
        private static List <Book> ListOfBooks()
        {
            List <Book> books = BookRepository.GetBooks();


            Console.WriteLine("Id  Title - Language - Year Of Publication - Pages - Author - Copies");

            for (int i = 0; i < books.Count; i++)
            {
                Console.WriteLine($"{i + 1}: Book: {books[i].Title} {books[i].Language} {books[i].YearOfPublication} {books[i].Pages} {books[i].Author} {books[i].Copies}");
            }

            return(books);
        }
Exemplo n.º 3
0
        /// <summary>
        /// select bookId to loan
        /// </summary>
        /// <returns>selected book id</returns>
        private Book SelectBook()
        {
            List <Book> books = BookRepository.GetBooks();

            Console.WriteLine("Id  Title - Language - Year Of Publication - Pages - Author - Copies");

            for (int j = 0; j < books.Count; j++)
            {
                Console.WriteLine($"{j + 1}: Book: {books[j].Title} {books[j].Language} {books[j].YearOfPublication} {books[j].Pages} {books[j].Author} {books[j].Copies}");
            }

            Console.Write("Choose book id to loan: ");
            string input          = Console.ReadLine();
            int    selectedNumber = int.Parse(input);

            return(books[selectedNumber - 1]);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Lets the user delete a book with the specific id
        /// </summary>
        private void DeleteBook()
        {
            Console.Clear();

            List <Book> books = BookRepository.GetBooks();;

            Console.WriteLine("Id  Title - Language - Year Of Publication - Pages - Author - Copies");

            for (int i = 0; i < books.Count; i++)
            {
                Console.WriteLine($"{i + 1}: Book: {books[i].Title} {books[i].Language} {books[i].YearOfPublication} {books[i].Pages} {books[i].Author} {books[i].Copies}");
            }


            Console.WriteLine("Choose book id to delete: ");
            string input          = Console.ReadLine();
            int    selectedNumber = int.Parse(input);
            Book   deleteBook     = books[selectedNumber - 1];


            BookRepository.DeleteBookById(deleteBook.Id);
        }