Menu completed

Commented out database connecting lines and added successful login in instead.
This commit is contained in:
Im_Alpha 2021-12-13 23:28:47 -08:00
parent 6f9c6f0f12
commit a4a133b0cd
4 changed files with 52 additions and 45 deletions

View File

@ -17,9 +17,9 @@ namespace TeamHobby.HobbyProjectGenerator.DataAccess
public SqlDAO(string info) public SqlDAO(string info)
{ {
try { try {
Console.WriteLine("Establising Connection..."); //Console.WriteLine("Establising Connection...");
_conn = new OdbcConnection(info); _conn = new OdbcConnection(info);
Console.WriteLine("Connection established."); //Console.WriteLine("Connection established.");
} }
catch { catch {
//_conn = null; //_conn = null;

View File

@ -17,7 +17,8 @@ namespace TeamHobby.HobbyProjectGenerator.DataAccess
{ {
// Menu for all UserManagement options // Menu for all UserManagement options
int menu = 0; int menu = 0;
Console.WriteLine($"Welcome {username} to User Management.\n"); Console.WriteLine("-------------------------------------\n");
Console.WriteLine($"\nWelcome {username} to User Management.\n");
Console.WriteLine("What would you like to do?\n"); Console.WriteLine("What would you like to do?\n");
Console.WriteLine(menu + ") To exit User Management.\n"); Console.WriteLine(menu + ") To exit User Management.\n");
menu += 1; menu += 1;

View File

@ -175,6 +175,7 @@ namespace TeamHobby.HobbyProjectGenerator.UserManagement
if (checkSql == "Admin") if (checkSql == "Admin")
{ {
Console.WriteLine("-- Logged in successfully.");
return true; return true;
} }
else else
@ -218,7 +219,6 @@ namespace TeamHobby.HobbyProjectGenerator.UserManagement
// Exit menu // Exit menu
case 0: case 0:
return "Exiting UserManagement.\n"; return "Exiting UserManagement.\n";
break;
// Create account // Create account
case 1: case 1:
UserAccount newUser = new UserAccount(newCredentials.GetUserName(), UserAccount newUser = new UserAccount(newCredentials.GetUserName(),
@ -266,8 +266,7 @@ namespace TeamHobby.HobbyProjectGenerator.UserManagement
case 7: case 7:
break; break;
default: default:
Console.WriteLine("Invalid input.\nPlease enter a valid option.\n" + Console.WriteLine("Invalid input.\nPlease enter a valid option.\n");
"------------------------------------\n\n");
break; break;
} }
} }

View File

@ -33,51 +33,58 @@ namespace TeamHobby.HobbyProjectGenerator.Main
// Change terminal height // Change terminal height
Console.WindowHeight = 40; Console.WindowHeight = 40;
Console.WriteLine(DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss"));
// Creating the Factory class // Creating the Factory class
// Logger log = new Logger(); // Logger log = new Logger();
//Logger.PrintTest(); //Logger.PrintTest();
// Admin login // Loop login terminal
GetCredentials credentials = new GetCredentials(); bool mainMenu = true;
string? username = credentials.GetUserName();
string? password = credentials.GetPassword(); // Loop Admin login
while (mainMenu is true)
{
// Admin Sign in
GetCredentials credentials = new GetCredentials();
Console.WriteLine("\nPlease Enter Admin Credentials.\n");
string? username = credentials.GetUserName();
string? password = credentials.GetPassword();
// Get time of login attempt
DateTime TimeStamp = DateTime.UtcNow;
// String for checking query return type
string dbType = "sql";
// Creating the Factory class
RDSFactory dbFactory = new RDSFactory();
// Testing Data Access Layer
string dbInfo = "DRIVER={MariaDB ODBC 3.1 Driver};" +
"TCPIP=1;" +
"SERVER=localhost;" +
"DATABASE=hobby;" +
"UID=root;" +
"PASSWORD=Teamhobby;" +
"OPTION=3";
IDataSource<string> datasource = dbFactory.getDataSource(dbType, dbInfo);
// Create manager class from UserManagement
SystemAccountManager manager = new SystemAccountManager();
// Create UserAccount class
UserAccount user = new UserAccount(username, password, TimeStamp);
string isLogin = manager.CreateUserRecord(user, datasource);
//Console.WriteLine(value: $"username is {username}\npassword is {password}"); if (isLogin != "Access Denied: Unauthorized\n")
{
// Creating the Factory class mainMenu = false;
// Creating the Factory class }
else
string dbType = "sql"; {
RDSFactory dbFactory = new RDSFactory(); Console.WriteLine("******Access Denied: Unauthorized******");
}
// Testing Data Access Layer
string dbInfo = "DRIVER={MariaDB ODBC 3.1 Driver};" + }
"TCPIP=1;" +
"SERVER=localhost;" +
"DATABASE=hobby;" +
"UID=root;" +
"PASSWORD=Teamhobby;" +
"OPTION=3";
IDataSource<string> datasource = dbFactory.getDataSource(dbType, dbInfo);
// Create manager class from UserManagement
SystemAccountManager manager = new SystemAccountManager();
/* // Admin Sign in
GetCredentials credentials = new GetCredentials();
string? username = credentials.GetUserName();
string? password = credentials.GetPassword();*/
// Get time of login attempt
DateTime TimeStamp = DateTime.UtcNow;
// Create UserAccount class
UserAccount user = new UserAccount(username, password, TimeStamp);
Console.Write(manager.CreateUserRecord(user, datasource));
//Console.WriteLine(value: $"Welcome {username}\n"); //Console.WriteLine(value: $"Welcome {username}\n");
/* string sqlQuery = "Select * from log;"; /* string sqlQuery = "Select * from log;";