示例#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 TopUpWalletFlow()
        {
            Console.WriteLine("Amount to be topped up");
            WalletServiceProvider walletService = new WalletServiceProvider(loggedInUser);
            decimal money = Convert.ToDecimal(Console.ReadLine());

            Console.WriteLine("Funds in the wallet now are Rs. " + walletService.TopUpWallet(money));
        }