Beispiel #1
0
        private static void EfRentalDalTest()
        {
            RentalManager rentalManager = new RentalManager(new EfRentalDal());

            Rental rental1 = new Rental
            {
                CarId      = 1,
                CustomerId = 2,
                RentDate   = DateTime.Now,
                ReturnDate = null
            };

            Rental rental2 = new Rental
            {
                CarId      = 2,
                CustomerId = 3,
                RentDate   = DateTime.Now,
                ReturnDate = null
            };

            Console.WriteLine("\nRent records in Rentals table: ");
            foreach (Rental rental in rentalManager.GetAll().Data)
            {
                Console.WriteLine("Rented at {0}", rental.RentDate);
            }

            Console.WriteLine("\nTrying to rent a booked car.");
            rentalManager.Rent(rental1);

            Console.WriteLine("\nTrying to rent an avaible car.");
            rentalManager.Rent(rental2);

            Console.WriteLine("\nRent records in Rentals table: ");
            foreach (Rental rental in rentalManager.GetAll().Data)
            {
                Console.WriteLine("Rented at {0}", rental.RentDate);
            }

            Console.WriteLine("\nCancelling a rental.");
            rentalManager.Cancel(rental2);

            Console.WriteLine("\nRent records in Rentals table: ");
            foreach (Rental rental in rentalManager.GetAll().Data)
            {
                Console.WriteLine("Rented at {0}", rental.RentDate);
            }
        }