Пример #1
0
        private static void PendingTransfersMenu()
        {
            Console.Clear();
            Console.WriteLine("----------------------------------------------");
            Console.WriteLine("Transfer");
            Console.WriteLine("IDs               From                  Amount");
            Console.WriteLine("----------------------------------------------");
            Console.WriteLine();

            List <Transfer> allTransfers = transferService.GetAllTransfers(UserService.GetUserId());


            List <Transfer> myPendingTransfers = PrintPendingTransfers(allTransfers);

            if (myPendingTransfers.Count == 0)
            {
                Console.WriteLine("There are no pending transfers for this user.");
                Console.WriteLine("----------------------------------------------");
                System.Threading.Thread.Sleep(5000);
                Console.WriteLine();
                Console.Clear();
            }
            else
            {
                Console.WriteLine("----------------------------------------------");
                Console.WriteLine();
                Console.Write("Please enter the Id of the transfer you would like to view (0 to exit) : ");
                int transferToView = -1;
                if (!int.TryParse(Console.ReadLine(), out transferToView))
                {
                    Console.Clear();
                    Console.WriteLine();
                    SomethingWentWrong();
                }
                else if (transferToView > 0)
                {
                    PrintTransferDetails(myPendingTransfers, transferToView);

                    Console.Write("Would you like to Approve or Reject this transfer? (A/R or press enter to exit) :");
                    string proceed = Console.ReadLine().ToLower();

                    if (proceed == "a" || proceed == "approve")
                    {
                        bool success = transferService.ApproveTransfer(UserService.GetUserId(), transferToView);

                        if (success)
                        {
                            Console.WriteLine();
                            Console.WriteLine("--------------------------------------------------------------");
                            Console.WriteLine("Transfer Approved.  ");
                            Console.WriteLine("--------------------------------------------------------------");
                            System.Threading.Thread.Sleep(3000);
                            Console.Clear();
                        }
                        else
                        {
                            Console.WriteLine();
                            Console.WriteLine("--------------------------------------------------------------");
                            Console.WriteLine("Error .  ");
                            Console.WriteLine("--------------------------------------------------------------");
                            SomethingWentWrong();
                            System.Threading.Thread.Sleep(3000);
                            Console.Clear();
                        }
                    }
                    else if (proceed == "r" || proceed == "reject")
                    {
                        transferService.RejectTransfer(UserService.GetUserId(), transferToView);
                    }
                    else
                    {
                        Console.Clear();
                    }
                }
                else
                {
                    Console.Clear();
                }
            }
        }