public static void HandleLoanMenu(string option) { LoanManagement loanManager = new LoanManagement(); double loanAmount; string loanType = string.Empty; bool isError = false; try { if (option.Equals("1")) { loanAmount = 100000; loanType = "House"; } else if (option.Equals("2")) { loanAmount = 500000; loanType = "car"; } else if (option.Equals("3")) { loanAmount = 1000000; loanType = "Business"; } else { isError = true; throw new Exception("Input not recognized."); } if (!isError) { loanManager.AddLoan(AccountHolderRepository.LoggedInAccount.Id, loanAmount, loanType); } } catch (Exception e) { Console.WriteLine($"Error: {e.Message}"); } finally { HandleAccountHolderMenu("2"); } }
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; } }