public void furtherAction() { Console.Write("Do you want to continue >> 1. Yes 2. No : "); int decision = Int32.Parse(Console.ReadLine()); Console.Clear(); switch (decision) { case 1: if (LoginMethods.CurrentUser.Type == "staff") { StaffActions staff = new StaffActions(); staff.DisplayMethods(); } else { SelectAction(); } break; case 2: Console.WriteLine("You are logged out"); login.ValidateUser(); break; default: Console.WriteLine("Invalid choice!!!"); furtherAction(); break; } }
public void furtherAction() { IUserActions userActions = new UserActions(); string decision = commonMethods.ReadString("Do you want to continue >> 1. Yes 2. No : "); Console.Clear(); if (decision == "Yes" || decision == "Y" || decision == "yes" || decision == "1") { if (LoginMethods.CurrentUser.Type == "staff") { StaffActions staff = new StaffActions(); staff.DisplayMethods(); } else { userActions.SelectAction(); } } else { Console.WriteLine("You are logged out"); login.ValidateUser(); } }
//Create Account public void CreateAccount() { string username = commonMethods.ReadString("Enter account user name : "); User user = userService.GetUser(username); if (user == null) { Console.WriteLine("Sorry!! There is no user with the given username.."); int choice = commonMethods.ValidateInt("Do you want to add a user >> 1. Yes 2. No : "); if (choice == 1) { IStaffActions staffActions = new StaffActions(); staffActions.AddUser(); } else if (choice != 1) { int AccountDecision = commonMethods.ValidateInt("Do you want to add an account >> 1. Yes 2. No : "); if (AccountDecision == 1) { CreateAccount(); } else { furtherAction(); } } } List <Account> checkAccounts = accountService.GetAllAccountsByName(username); if (checkAccounts.Count != 0) { List <int> types = new List <int>(); foreach (Account acccount in checkAccounts) { types.Add(Convert.ToInt32(acccount.Type)); } Console.WriteLine("Enter the type of account you want to create : "); for (int i = 1; i <= 4; i++) { if (types.Exists(obj => obj == i)) { continue; } else { Console.Write(i + " " + Enum.GetName(typeof(AccountType), i) + " "); } } Console.WriteLine("5. Exit"); int accountDecision = commonMethods.ValidateInt("Please enter your choice : "); while (types.Exists(obj => obj == accountDecision) || accountDecision > 6 || accountDecision <= 0) { if (types.Exists(obj => obj == accountDecision)) { Console.WriteLine("Account already exists!!!"); int accountChoice = commonMethods.ValidateInt("Do you want to create another account : 1. Yes 2. No >> "); if (accountChoice == 1) { CreateAccount(); } furtherAction(); } if (accountDecision == 5) { furtherAction(); } accountDecision = commonMethods.ValidateInt("Please enter a valid choice : "); } Account newAccount = new Account() { Balance = 0, Id = Guid.NewGuid(), Number = username.Substring(0, 3) + DateTime.Now, BankId = LoginMethods.CurrentBank.Id, Type = (AccountType)accountDecision }; accountService.CreateAccount(newAccount); Console.WriteLine("Account added successfully!!!"); furtherAction(); } Console.WriteLine("Please enter the type of account you want to create : "); for (int i = 1; i <= 4; i++) { Console.Write(i + " " + Enum.GetName(typeof(AccountType), i) + " "); } Console.WriteLine("5. Exit"); int decision = commonMethods.ValidateInt("Please enter your choice : "); while (decision > 6 || decision <= 0) { if (decision == 5) { furtherAction(); } decision = commonMethods.ValidateInt("Please enter a valid choice : "); } string accountNumber = username.Substring(0, 3) + DateTime.Now; Account account = new Account() { Id = Guid.NewGuid(), Number = accountNumber, Balance = 0, UserName = username, BankId = LoginMethods.CurrentBank.Id, Type = (AccountType)decision }; accountService.CreateAccount(account); Console.WriteLine("Account added successfully!!!"); furtherAction(); }
public void ValidateUser() { Console.Clear(); Console.WriteLine("<----------WELCOME TO LOGIN PAGE---------->"); string userName = commonMethods.ReadString("Enter your username : "******"Incorrect UserName, Please enter a valid username"); userName = commonMethods.ReadString("Enter a valid username : "******"Enter your password : "******"admin") { Console.Clear(); AdminMethods adminMethods = new AdminMethods(); adminMethods.AdminActions(); } GetBank(userName); List <Account> accounts = accountService.GetAllAccountsByName(userName); if (accounts.Count == 0 && CurrentUser.Type == "staff") { CurrentAccount = null; StaffActions staff = new StaffActions(); staff.DisplayMethods(); } else if (accounts.Count == 1) { CurrentAccount = accounts[0]; if (CurrentUser.Type == "staff") { StaffActions staff = new StaffActions(); staff.DisplayMethods(); } UserActions user = new UserActions(); user.SelectAction(); } else { Console.Write("Enter the account you want to login into : "); int i = 1; foreach (Account account in accounts) { Console.Write(i + " " + Enum.GetName(typeof(AccountType), account.Type) + " "); i += 1; } Console.WriteLine(); int choice = commonMethods.ValidateInt("Please enter your account choice : "); while ((!accounts.Exists(obj => Convert.ToInt32(obj.Type) == choice)) || choice > accounts.Count || choice < 0) { Console.Write("Please enter a valid choice : "); choice = Int32.Parse(Console.ReadLine()); } CurrentAccount = accounts[choice - 1]; if (CurrentUser.Type == "staff") { StaffActions staff = new StaffActions(); staff.DisplayMethods(); } UserActions user = new UserActions(); user.SelectAction(); } } else { Console.WriteLine("Sorry!! You've entered invalid credentials.."); Console.WriteLine("Please enter valid credentials "); System.Threading.Thread.Sleep(1500); ValidateUser(); } }