Ejemplo n.º 1
0
        public void GetValidBookings()
        {
            var bookings      = BookingsRepository.GetAll();
            var validBookings = bookings.Where(x => x.ToDate < DateTime.Now && x.IsCancelled == false).ToList();

            validBookings.ForEach(x => x.PrintInfo());
        }
Ejemplo n.º 2
0
        public void CancelBooking()
        {
            Customers customer = FindCustomerByEmail();

            Console.WriteLine("Please enter booking reference code:");
            var refCode  = Console.ReadLine();
            var bookings = BookingsRepository.GetAll();
            var booking  = bookings.FirstOrDefault(x => x.RefCode == refCode && x.FromDate > DateTime.Now && x.CustomerId == customer.Id);

            if (booking == null)
            {
                throw new FlowException("Booking not found!");
            }
            Console.WriteLine($"Confirm you want to cancel booking {booking.RefCode}? Enter y if yes!");
            var confirm = Console.ReadLine();

            if (confirm.ToLower() == "y")
            {
                booking.IsCancelled = true;
            }
            BookingsRepository.Update(booking);
            BookingsRepository.SaveEntities();
            Console.WriteLine("Booking is cancelled!Please check your credit card after 10 minutes!");
        }