Пример #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();
     }
 }
Пример #2
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);
                    }
                }
            }
        }