public List <Customer> GetAllForBook(Book book)
 {
     return(reservationDAO.GetAllForBook(book));
 }
Beispiel #2
0
        bool Start()
        {
            Book book1 = new Book(1, "Dracula", "Bram Stoker");
            Book book2 = new Book(2, "Joe Speedboot", "Tommy Wieringa");
            Book book3 = new Book(3, "The Hobbit", "J.R.R. Tolkien");

            Customer customer1 = new Customer(1, "Lionel", "Messi", "*****@*****.**");
            Customer customer2 = new Customer(2, "Piet", "Paulusma", "*****@*****.**");

            Reservation reservation1 = new Reservation(1, customer1, book1);
            Reservation reservation2 = new Reservation(1, customer1, book3);
            Reservation reservation3 = new Reservation(1, customer2, book2);
            Reservation reservation4 = new Reservation(1, customer2, book1);

            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("Books");
            Console.ResetColor();
            Console.WriteLine(book1);
            Console.WriteLine(book2);
            Console.WriteLine(book3);

            Console.WriteLine();

            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("Customers");
            Console.ResetColor();
            Console.WriteLine(customer1);
            Console.WriteLine(customer2);

            Console.WriteLine();

            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("Reservations");
            Console.ResetColor();
            Console.WriteLine(reservation1);
            Console.WriteLine(reservation2);
            Console.WriteLine(reservation3);
            Console.WriteLine(reservation4);

            Console.WriteLine();

            CustomerDAO customerDAO = new CustomerDAO();

            foreach (Customer cust in customerDAO.GetAll())
            {
                Console.WriteLine(cust);
            }
            Customer customer = customerDAO.GetById(2);

            Console.WriteLine();
            Console.WriteLine("Searching for customer with id 2...");
            if (customer != null)
            {
                Console.WriteLine(customer);
            }
            else
            {
                Console.WriteLine("Customer not found!");
            }

            Console.WriteLine();

            BookDAO bookDAO = new BookDAO();

            foreach (Book b in bookDAO.GetAll())
            {
                Console.WriteLine($"{b.Id}. {b}");
            }
            Book book = bookDAO.GetById(2);

            Console.WriteLine();
            Console.WriteLine("Searching for book with id 2...");
            if (book != null)
            {
                Console.WriteLine(book);
            }
            else
            {
                Console.WriteLine("Book not found!");
            }

            Console.WriteLine();

            ReservationDAO reservationDAO = new ReservationDAO();

            foreach (Reservation res in reservationDAO.GetAll())
            {
                Console.WriteLine(res);
            }
            List <Book> books = reservationDAO.GetAllForCustomer(customerDAO.GetById(2));

            Console.WriteLine();
            Console.WriteLine("Searching for books reserved by customer with id 2...");
            if (books.Count != 0)
            {
                foreach (Book b in books)
                {
                    Console.WriteLine(b);
                }
            }
            else
            {
                Console.WriteLine("Books not found!");
            }
            List <Customer> customers = reservationDAO.GetAllForBook(bookDAO.GetById(3));

            Console.WriteLine();
            Console.WriteLine("Searching for customers who reserved book with id 3...");
            if (customers.Count != 0)
            {
                foreach (Customer cust in customers)
                {
                    Console.WriteLine(cust);
                }
            }
            else
            {
                Console.WriteLine("Customers not found!");
            }

            return(ProgramTools.LoopProgram());
        }
Beispiel #3
0
        void Start()
        {
            CustomerDAO    customerDAO    = new CustomerDAO();
            BookDAO        bookDAO        = new BookDAO();
            ReservationDAO reservationDAO = new ReservationDAO();

            foreach (Customer c in customerDAO.GetAll())
            {
                Console.WriteLine(c);
            }

            Console.WriteLine();

            Customer customer = customerDAO.GetById(2);

            if (customer != null)
            {
                Console.WriteLine(customer);
            }
            else
            {
                Console.WriteLine("Customer not found");
            }

            Console.WriteLine();
            Console.WriteLine();

            foreach (Book b in bookDAO.GetAll())
            {
                Console.WriteLine(b);
            }

            Console.WriteLine();

            Book book = bookDAO.GetById(2);

            if (book != null)
            {
                Console.WriteLine(book);
            }
            else
            {
                Console.WriteLine("Book not found");
            }

            Console.WriteLine();
            Console.WriteLine();

            foreach (Reservation r in reservationDAO.GetAll())
            {
                Console.WriteLine(r);
            }

            Console.WriteLine();

            foreach (Reservation r in reservationDAO.GetAllForCustomer(customer))
            {
                Console.WriteLine(r);
            }

            Console.WriteLine();

            foreach (Reservation r in reservationDAO.GetAllForBook(book))
            {
                Console.WriteLine(r);
            }
        }