Пример #1
0
        public static void SaveMoney()
        {
            OverdraftManagement overdraftManagement = new OverdraftManagement();

            Console.Clear();
            Console.WriteLine("     ACCOUNT DEPOSIT MENU");
            Console.Write("How Much Do You Want To Save: ");

            double amountToSave = Convert.ToDouble(Console.ReadLine());

            overdraftManagement.PayOverdraft(LoggedInAccount, amountToSave);

            LoggedInAccount.AccountBalance += amountToSave;
            RefreshList();
            RefreshFile();
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine($"You have succesfully Deposited {amountToSave} into your account.");
            Console.WriteLine($"New Balance is {LoggedInAccount.AccountBalance}");

            Menu.ShowContinueMenu();
        }
Пример #2
0
        public static void Transfer(string accountNumber, double amountToTransfer)

        {
            OverdraftManagement overdraftManagement = new OverdraftManagement();

            try
            {
                AccountHolder accountToTransferTo = FindByAccountNumber(accountNumber);

                if (accountNumber == null)
                {
                    throw new Exception($"Account Holder with {accountNumber} Does Not Exist");
                }
                else
                {
                    if (LoggedInAccount.AccountBalance < amountToTransfer)
                    {
                        throw new Exception($"Insufficient Funds");
                    }
                    else
                    {
                        Console.Write($" Are You Sure You Want To Transfer {amountToTransfer} to {accountToTransferTo.FirstName} {accountToTransferTo.LastName} {accountToTransferTo.MiddleName}..  y/n : ");
                        string answer = Console.ReadLine().ToLower();
                        if (answer.Equals("y"))
                        {
                            if (LoggedInAccount.Pin == 0)
                            {
                                Console.WriteLine("You have To Set Your Pin");
                                Menu.ShowContinueMenu();
                                ChangePin();
                            }
                            else
                            {
                                Console.WriteLine("Enter Your Pin");
                                int pin = Convert.ToInt32(Console.ReadLine());

                                if (LoggedInAccount.Pin == pin)
                                {
                                    overdraftManagement.PayOverdraft(accountToTransferTo, amountToTransfer);

                                    accountToTransferTo.AccountBalance += amountToTransfer;
                                    LoggedInAccount.AccountBalance     -= amountToTransfer;
                                    Console.ForegroundColor             = ConsoleColor.Green;
                                    Console.WriteLine("Transfer Succesful");
                                    RefreshList();
                                    RefreshFile();
                                    Menu.ShowContinueMenu();
                                }
                                else
                                {
                                    throw new Exception("Incorrect Pin");
                                }
                            }
                        }
                        else if (answer.Equals("n"))
                        {
                            Console.WriteLine("Operation Cancelled");
                        }
                        else
                        {
                            throw new Exception("Operation Cancelled");
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine(ex.Message);
                Menu.ShowContinueMenu();
            }
        }