示例#1
0
        static void PaymentFlow()
        {
            BookingServiceProvider bookingService = new BookingServiceProvider(loggedInUser);
            WalletServiceProvider  walletService  = new WalletServiceProvider(loggedInUser);
            List <Booking>         Completed      = bookingService.ViewCompletedRides();

            if (Completed.ToArray().Length == 0)
            {
                Console.WriteLine("No trips made so far!");
                Menu();
            }
            else
            {
                List <Booking>       SortedBookings    = Completed.OrderByDescending(o => o.DateCreated).ToList();
                Repository <Booking> bookingDataAccess = new Repository <Booking>();
                Console.WriteLine("Your last ride from " + SortedBookings.ElementAt(0).StartPoint + " to " + SortedBookings.ElementAt(0).EndPoint + " amounts to Rs. " + SortedBookings.ElementAt(0).Price);
                if (walletService.IsFundSufficient(SortedBookings.ElementAt(0).Price))
                {
                    decimal LeftMoney = walletService.DeductWalletFund(SortedBookings.ElementAt(0).Price);
                    bookingDataAccess.Remove(SortedBookings.ElementAt(0));
                    SortedBookings.ElementAt(0).IsPaid = true;
                    bookingDataAccess.Add(SortedBookings.ElementAt(0));
                    Console.WriteLine("Money left is Rs. " + LeftMoney);
                }
                else
                {
                    Console.WriteLine("Wallet money not sufficient");
                    Console.WriteLine("Redirecting to Top Up!");
                    TopUpWalletFlow();
                }
            }
        }
示例#2
0
        static void RideHistoryFlow()
        {
            BookingServiceProvider bookingService = new BookingServiceProvider(loggedInUser);
            List <Booking>         completed      = bookingService.ViewCompletedRides();

            foreach (Booking display in completed)
            {
                AttributeDisplayHelper.DisplayAttributes <Booking>(display);
            }
        }