Example #1
0
 public static void UpdateAccountHolderMenu(int id, string updateOption)
 {
     try
     {
         if (updateOption.Equals("1"))
         {
             Console.Write("Enter New First Name: ");
             string changeFirstName = Console.ReadLine();
             AccountHolderRepository.UpdateAccountHolder(id, firstName: changeFirstName);
         }
         else if (updateOption.Equals("2"))
         {
             Console.Write("Enter New Last Name: ");
             string changeLastName = Console.ReadLine();
             AccountHolderRepository.UpdateAccountHolder(id, lastName: changeLastName);
         }
         else if (updateOption.Equals("3"))
         {
             Console.Write("Enter New Middle Name: ");
             string changeMiddleName = Console.ReadLine();
             AccountHolderRepository.UpdateAccountHolder(id, middleName: changeMiddleName);
         }
         else if (updateOption.Equals("4"))
         {
             Console.Write("Enter New Phone Number: ");
             string changePhoneNumber = Console.ReadLine();
             AccountHolderRepository.UpdateAccountHolder(id, phoneNumber: changePhoneNumber);
         }
         else if (updateOption.Equals("5"))
         {
             Console.Write("Enter Your New Address: ");
             string changeAddress = Console.ReadLine();
             AccountHolderRepository.UpdateAccountHolder(id, address: changeAddress);
         }
         else
         {
             throw new Exception("Input  Not Recognized");
         }
     }
     catch (Exception e)
     {
         Console.ForegroundColor = ConsoleColor.Red;
         Console.WriteLine($"Error: {e.Message}");
     }
     finally
     {
         ShowContinueMenu();
     }
 }
Example #2
0
        public static void RegisterAccountHolder()
        {
            accountHolder = new AccountHolderRepository();
            Random random = new Random();

            Console.Clear();
            Console.WriteLine("     ACCOUNT HOLDER REGISTRATION");
            Console.Write("Enter your ID: ");
            int id = Convert.ToInt32(Console.ReadLine());

            Console.Write("Enter your First Name: ");
            string firstName = Console.ReadLine();

            Console.Write("Enter your Middle Name: ");
            string middleName = Console.ReadLine();

            Console.Write("Enter your Last Name: ");
            string lastName = Console.ReadLine();

            Console.Write("Enter your Date Of Birth (yyyy/mm/dd): ");
            DateTime dateOfBirth = Convert.ToDateTime(Console.ReadLine());

            Console.Write("Enter your Email Address: ");
            string email = Console.ReadLine();

            Console.Write("Enter your Phone Number: ");
            string phoneNumber = Console.ReadLine();

            Console.Write("Enter your Address: ");
            string address = Console.ReadLine();

            Console.Write("Enter your Password: "******"Confirm your Password:  "******"00000");
            string secondFive    = random.Next(1, 10000).ToString("00000");
            string accountNumber = firstFive + secondFive;

            accountHolder.CreateAccountHolder(id, firstName, middleName, lastName, dateOfBirth, email, phoneNumber, address, password, confirmPassword, accountNumber);
        }
Example #3
0
        public static bool LoginAccountHolder()
        {
            accountHolder = new AccountHolderRepository();
            if (isHolderLoggedIn == true)
            {
                return(isHolderLoggedIn);
            }
            else
            {
                Console.Clear();
                Console.WriteLine("    ACCOUNT HOLDER LOGIN");
                Console.Write("Enter your email: ");
                string email = Console.ReadLine();

                int userId = AccountHolderRepository.LoginAccountHolder(email);
                isHolderLoggedIn = (userId != 0);

                return(isHolderLoggedIn);
            }
        }
Example #4
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;
            }
        }
Example #5
0
        public static void HandleLoggedInManagerOperations(string option)
        {
            //AccountHolderRepository accountHolderRepository = new AccountHolderRepository();
            if (option.Equals("0"))
            {
                Auth.LogoutAccountManager();
                HandleSubMenu("2");
            }
            else if (option.Equals("1"))
            {
                Console.Clear();
                Console.WriteLine("     LIST OF ACCOUNT HOLDERS");
                AccountHolderRepository acc = new AccountHolderRepository();
                AccountHolderRepository.ListAccountHolders();
                ShowContinueMenu();
                HandleAccountManagerMenu("2");
            }
            else if (option.Equals("2"))
            {
                Console.Clear();
                Console.WriteLine("   ACCOUNT HOLDER DELETE MENU");
                Console.Write("Enter Account Id: ");
                int id = Convert.ToInt32(Console.ReadLine());

                AccountHolderRepository.RemoveAccountHolder(id: id);
                ShowContinueMenu();
                HandleAccountManagerMenu("2");
            }
            else if (option.Equals("3"))
            {
                Console.Clear();
                Console.WriteLine("   ACCOUNT HOLDER UPDATE MENU");
                Console.Write("Enter Account Id: ");
                int id = Convert.ToInt32(Console.ReadLine());

                AccountHolder account = AccountHolderRepository.FindById(id);
                if (account == null)
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("Account doesn't exist");
                    Menu.ShowContinueMenu();
                }
                else
                {
                    Menu.ShowAccountManagerUpdateMenu();

                    string updateOption = Console.ReadLine();

                    if (updateOption.Equals("6"))
                    {
                        Console.Write("Enter New Account Status(active/inactive): ");
                        string changeAccountStatus = Console.ReadLine().ToLower();
                        if (changeAccountStatus.Equals("active") || changeAccountStatus.Equals("inactive"))
                        {
                            AccountHolderRepository.UpdateAccountHolder(id, status: changeAccountStatus);
                        }
                        else
                        {
                            Console.ForegroundColor = ConsoleColor.Red;
                            Console.WriteLine("Invalid input");
                        }
                        ShowContinueMenu();
                        HandleAccountManagerMenu("2");
                    }
                    else
                    {
                        UpdateAccountHolderMenu(id, updateOption);
                    }
                }
            }
        }
Example #6
0
 public static void LogOutAccountHolder()
 {
     isHolderLoggedIn = false;
     AccountHolderRepository.LogOutAccountHolder();
 }
Example #7
0
 public Auth()
 {
     accountHolder = new AccountHolderRepository();
 }