Menu completed
Commented out database connecting lines and added successful login in instead.
This commit is contained in:
parent
6f9c6f0f12
commit
a4a133b0cd
@ -17,9 +17,9 @@ namespace TeamHobby.HobbyProjectGenerator.DataAccess
|
||||
public SqlDAO(string info)
|
||||
{
|
||||
try {
|
||||
Console.WriteLine("Establising Connection...");
|
||||
//Console.WriteLine("Establising Connection...");
|
||||
_conn = new OdbcConnection(info);
|
||||
Console.WriteLine("Connection established.");
|
||||
//Console.WriteLine("Connection established.");
|
||||
}
|
||||
catch {
|
||||
//_conn = null;
|
||||
|
||||
@ -17,7 +17,8 @@ namespace TeamHobby.HobbyProjectGenerator.DataAccess
|
||||
{
|
||||
// Menu for all UserManagement options
|
||||
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(menu + ") To exit User Management.\n");
|
||||
menu += 1;
|
||||
|
||||
@ -175,6 +175,7 @@ namespace TeamHobby.HobbyProjectGenerator.UserManagement
|
||||
|
||||
if (checkSql == "Admin")
|
||||
{
|
||||
Console.WriteLine("-- Logged in successfully.");
|
||||
return true;
|
||||
}
|
||||
else
|
||||
@ -218,7 +219,6 @@ namespace TeamHobby.HobbyProjectGenerator.UserManagement
|
||||
// Exit menu
|
||||
case 0:
|
||||
return "Exiting UserManagement.\n";
|
||||
break;
|
||||
// Create account
|
||||
case 1:
|
||||
UserAccount newUser = new UserAccount(newCredentials.GetUserName(),
|
||||
@ -266,8 +266,7 @@ namespace TeamHobby.HobbyProjectGenerator.UserManagement
|
||||
case 7:
|
||||
break;
|
||||
default:
|
||||
Console.WriteLine("Invalid input.\nPlease enter a valid option.\n" +
|
||||
"------------------------------------\n\n");
|
||||
Console.WriteLine("Invalid input.\nPlease enter a valid option.\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -33,24 +33,28 @@ namespace TeamHobby.HobbyProjectGenerator.Main
|
||||
// Change terminal height
|
||||
Console.WindowHeight = 40;
|
||||
|
||||
Console.WriteLine(DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss"));
|
||||
|
||||
// Creating the Factory class
|
||||
// Logger log = new Logger();
|
||||
//Logger.PrintTest();
|
||||
|
||||
// Admin login
|
||||
// Loop login terminal
|
||||
bool mainMenu = true;
|
||||
|
||||
// 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;
|
||||
|
||||
//Console.WriteLine(value: $"username is {username}\npassword is {password}");
|
||||
|
||||
// Creating the Factory class
|
||||
// Creating the Factory class
|
||||
|
||||
// String for checking query return type
|
||||
string dbType = "sql";
|
||||
// Creating the Factory class
|
||||
RDSFactory dbFactory = new RDSFactory();
|
||||
|
||||
// Testing Data Access Layer
|
||||
@ -65,19 +69,22 @@ namespace TeamHobby.HobbyProjectGenerator.Main
|
||||
// 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));
|
||||
string isLogin = manager.CreateUserRecord(user, datasource);
|
||||
|
||||
|
||||
if (isLogin != "Access Denied: Unauthorized\n")
|
||||
{
|
||||
mainMenu = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("******Access Denied: Unauthorized******");
|
||||
}
|
||||
|
||||
}
|
||||
//Console.WriteLine(value: $"Welcome {username}\n");
|
||||
|
||||
/* string sqlQuery = "Select * from log;";
|
||||
|
||||
Loading…
Reference in New Issue
Block a user