Ejemplo n.º 1
0
        public static void GetOverdraft(double overdraftAmount)
        {
            OverdraftManagement overdraftManagement = new OverdraftManagement();

            overdraftManagement.GetOverdraft(AccountHolderRepository.LoggedInAccount, overdraftAmount);
            LoggedInAccount.AccountBalance -= overdraftAmount;
            RefreshList();
            RefreshFile();
        }
Ejemplo n.º 2
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();
        }
Ejemplo n.º 3
0
        public static void HandleLoggedInAccountHolderMenu(string option)
        {
            LoanManagement      loanManagement      = new LoanManagement();
            OverdraftManagement overdraftManagement = new OverdraftManagement();

            switch (option)
            {
            case "0":
                HandleSubMenu("1");
                break;

            case "1":
                AccountHolderRepository.SaveMoney();
                HandleAccountHolderMenu("2");
                break;

            case "2":
                Menu.ResetMenuSettings();
                Console.WriteLine("    TRANSFER MENU");
                Console.WriteLine("Enter Account Number");
                string accountNumber = Console.ReadLine();
                Console.WriteLine("How Much Do You Want To Transfer?");
                double amountToTransfer = Convert.ToDouble(Console.ReadLine());

                AccountHolderRepository.Transfer(accountNumber, amountToTransfer);
                HandleAccountHolderMenu("2");
                break;

            case "3":
                AccountHolderRepository.WithdrawMoney();
                HandleAccountHolderMenu("2");
                break;

            case "4":
                AccountHolderRepository.CheckBalance();
                HandleAccountHolderMenu("2");
                break;

            case "5":
                ShowLoanServiceMenu();
                string loanOption = Console.ReadLine();
                if (loanOption.Equals("0"))
                {
                    HandleAccountHolderMenu("2");
                }
                else if (loanOption.Equals("1"))
                {
                    ShowLoanMenu();
                    string minOption = Console.ReadLine();
                    if (minOption.Equals("0"))
                    {
                        HandleAccountHolderMenu("2");
                    }
                    else
                    {
                        HandleLoanMenu(minOption);
                    }
                }
                else if (loanOption.Equals("2"))
                {
                    if (loanManagement.checkLoanBalance(AccountHolderRepository.LoggedInAccount.Id, false))
                    {
                        Menu.ResetMenuSettings();
                        Console.WriteLine("     LOAN PAYBACK MENU");
                        Console.Write("How much do you want to pay: ");
                        double amountToPay = Convert.ToDouble(Console.ReadLine());
                        loanManagement.payBackLoan(AccountHolderRepository.LoggedInAccount.Id, amountToPay);
                    }
                    Menu.ShowContinueMenu();
                    HandleAccountHolderMenu("2");
                }
                else if (loanOption.Equals("3"))
                {
                    loanManagement.checkLoanBalance(AccountHolderRepository.LoggedInAccount.Id);
                    Menu.ShowContinueMenu();
                    HandleAccountHolderMenu("2");
                }
                break;

            case "6":
                ResetMenuSettings();
                Console.WriteLine("     OVERDRAFT MENU");
                Console.Write("How much overdraft?: ");
                double overdraftAmount = Convert.ToDouble(Console.ReadLine());
                if (overdraftAmount > 100000)
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("Overdraft limit exceeded. Maximum overdraft is 100,000");
                }
                else if (overdraftAmount <= AccountHolderRepository.LoggedInAccount.AccountBalance)
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("Overdraft less than or equal to account balance. Please proceed to withdrawal");
                }
                else
                {
                    if (!overdraftManagement.checkOverdraftBalance(AccountHolderRepository.LoggedInAccount.Id))
                    {
                        AccountHolderRepository.GetOverdraft(overdraftAmount);
                    }
                }

                ShowContinueMenu();
                HandleAccountHolderMenu("2");
                break;

            case "7":
                ShowAccountHolderUpdateMenu();
                string updateOption = Console.ReadLine();
                UpdateAccountHolderMenu(AccountHolderRepository.LoggedInAccount.Id, updateOption);
                HandleAccountHolderMenu("2");
                break;

            case "8":
                AccountHolderRepository.ChangePassword();
                HandleAccountHolderMenu("2");
                break;

            case "9":
                AccountHolderRepository.SetPin();
                HandleAccountHolderMenu("2");
                break;

            default:
                break;
            }
        }
Ejemplo n.º 4
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();
            }
        }