Merge pull request #8 from long237/Jacobs-Branch

Jacobs branch
This commit is contained in:
Jacob Delgado 2021-12-10 18:34:33 -08:00 committed by GitHub
commit 3f7597e1eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 549 additions and 11 deletions

View File

@ -32,16 +32,18 @@ namespace TeamHobby.HobbyProjectGenerator.DAL
{
Console.WriteLine(r.ToString());
}
return null;
}
/*
* this is meant for specific basic sql commands
/*// this is meant for specific basic sql commands
using (var adapter = new SqlDataAdapter())
{
adapter.UpdateCommand
adapter.DeleteCommand
adapter.InsertCommand
adapter.SelectCommand
}
*/
}*/
}
}
}

View File

@ -1,10 +1,55 @@
using TeamHobby.HobbyProjectGenerator;
using System;
using Microsoft.Data.SqlClient;
using TeamHobby.HobbyProjectGenerator;
using TeamHobby.HobbyProjectGenerator.DAL;
using TeamHobby.HobbyProjectGenerator.Models;
namespace TeamHobby.HobbyProjectGenerator.Main
{
public class ExampleDAO : SqlDAO
public class ExampleDAO
{
public void UserData(string username)
{
// Sql server connection string, needs to be changed accordingly to connect
var connString = "server=localhost,3316;user=root;database=users;password=Plop20"; // Using @" " makes the string literal
// ADO.NET - ODBC
using var conn = new SqlConnection(connString);
{
// More complex sql commands are done in this method instead
var sql = "Select * from roles";
using (var command = new SqlCommand(sql, conn))
{
conn.Open();
// Get the results from the query
SqlDataReader r = command.ExecuteReader();
// If you wanted to get a singular value back such as a count of a certain item
//command.ExecuteScalar();
// To execute something that doesn't expect results to come back
// Use this method instead, IE. Update command
//command.ExecuteNonQuery();
// Read data from query
while (r.Read())
{
Console.WriteLine(r.ToString());
}
conn.Close();
}
// Console.Read();
/*
* this is meant for specific basic sql commands
using (var adapter = new SqlDataAdapter())
{
adapter.SelectCommand
}
*/
//return null;
}
}
}
}

View File

@ -1,4 +1,4 @@
/*
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
@ -27,3 +27,4 @@ app.MapControllerRoute(
app.Run();
*/

View File

@ -4,6 +4,8 @@
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<OutputType>Exe</OutputType>
<StartupObject></StartupObject>
</PropertyGroup>
<ItemGroup>

View File

@ -0,0 +1,49 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.31919.166
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TeamHobby.HobbyProjectGenerator", "TeamHobby.HobbyProjectGenerator.csproj", "{C75B6909-FD9E-4382-94B6-7CA2CE371C9A}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TeamHobby.UserManagement.Tests", "..\TeamHobby.UserManagement.Tests\TeamHobby.UserManagement.Tests.csproj", "{5C5A44B4-EC3C-44F2-8F39-F917F8ED932F}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TeamHobby.HobbyProjectGenerator.DAL", "..\TeamHobby.HobbyProjectGenerator.DAL\TeamHobby.HobbyProjectGenerator.DAL.csproj", "{DCB0E160-1F6D-406E-8633-489CD564479B}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TeamHobby.HobbyProjectGenerator.Models", "..\TeamHobby.HobbyProjectGenerator.Models\TeamHobby.HobbyProjectGenerator.Models.csproj", "{75DED6C2-D404-4E71-A58B-0F616DB5C062}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "main", "..\main\main.csproj", "{30C7EBF3-3957-46E5-86C1-C13356841ECA}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{C75B6909-FD9E-4382-94B6-7CA2CE371C9A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C75B6909-FD9E-4382-94B6-7CA2CE371C9A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C75B6909-FD9E-4382-94B6-7CA2CE371C9A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C75B6909-FD9E-4382-94B6-7CA2CE371C9A}.Release|Any CPU.Build.0 = Release|Any CPU
{5C5A44B4-EC3C-44F2-8F39-F917F8ED932F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5C5A44B4-EC3C-44F2-8F39-F917F8ED932F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5C5A44B4-EC3C-44F2-8F39-F917F8ED932F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5C5A44B4-EC3C-44F2-8F39-F917F8ED932F}.Release|Any CPU.Build.0 = Release|Any CPU
{DCB0E160-1F6D-406E-8633-489CD564479B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DCB0E160-1F6D-406E-8633-489CD564479B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DCB0E160-1F6D-406E-8633-489CD564479B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DCB0E160-1F6D-406E-8633-489CD564479B}.Release|Any CPU.Build.0 = Release|Any CPU
{75DED6C2-D404-4E71-A58B-0F616DB5C062}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{75DED6C2-D404-4E71-A58B-0F616DB5C062}.Debug|Any CPU.Build.0 = Debug|Any CPU
{75DED6C2-D404-4E71-A58B-0F616DB5C062}.Release|Any CPU.ActiveCfg = Release|Any CPU
{75DED6C2-D404-4E71-A58B-0F616DB5C062}.Release|Any CPU.Build.0 = Release|Any CPU
{30C7EBF3-3957-46E5-86C1-C13356841ECA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{30C7EBF3-3957-46E5-86C1-C13356841ECA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{30C7EBF3-3957-46E5-86C1-C13356841ECA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{30C7EBF3-3957-46E5-86C1-C13356841ECA}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {B2517200-A9F9-468C-B0EB-280FF9B9FBC9}
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,145 @@
using main;
using System;
namespace TeamHobby.HobbyProjectGenerator.Main
{
public class Controller
{
public bool newAccount()
{
// Get username
Console.WriteLine("Please enter a username:");
string userName = Console.ReadLine();
// Get Password
Console.WriteLine("Please enter a password:");
string userPassword = Console.ReadLine();
// Create bool value for password confirm loop
bool conPsswrd = true;
// Loop until password is confirmed
while (conPsswrd == true)
{
// Confirm Password
Console.WriteLine("Please re-enter the password:");
string checkPsswd = Console.ReadLine();
// Check if passwords match
if (userPassword == checkPsswd)
{
// Get Security question for password reset
Console.WriteLine("Please enter a security question.\n" +
"(EX: What is your favorite food?");
string SecQuest = Console.ReadLine();
// Get Security question answer
Console.WriteLine("Please enter the answer for your security question:");
String SecAnswer = Console.ReadLine();
// Call user manager method to create the new user
//int userCreateConfirm = new CreateUser(userName,userPassword,SecQuest,SecAnswer);
// Check if user creation was successful
/* if (userCreateConfirm = 1)
{
// Confirm to user that the account has been created
Console.WriteLine("Account created succesfully with the username of" + userName);
}
else
{
}*/
conPsswrd = false;
}
else
{
Console.WriteLine("Passwords did not match, please try again.");
}
}
return true;
}
static void Main(string[] args)
{
/* ExampleDAO z = new ExampleDAO();
z.UserData("Tomato");
Console.Read();*/
bool MainMenu = true;
// Set up menu loop
while (MainMenu == true)
{
// Console customization
// Change the look of the console
Console.Title = "HobbyProjectGenerator";
// Change console text color
Console.ForegroundColor = ConsoleColor.Green;
// Change terminal height
Console.WindowHeight = 40;
// Create class objects
UiPrint menu = new UiPrint();
UserAccount user = new UserAccount();
// Print main menu
menu.InitialMenu();
// Set up try-catch for invalid inputs
try
{
// Get user choice
string initialChoice = Console.ReadLine();
// Convert to integer
int Choice = Convert.ToInt32(initialChoice);
switch (Choice)
{
case 0:
MainMenu = false;
break;
// Create a new account
case 1:
user.newUser();
break;
// Access Admin features
case 2:
// Ask for Admin login credentials
Console.WriteLine("Please enter a username:");
string AdminUser = Console.ReadLine();
Console.WriteLine("Please enter the password for" + AdminUser);
string AdminPsswrd = Console.ReadLine();
// Check if the username and password match a record within the administrators
// Show new administrator menu
int AdminNum = 0;
Console.WriteLine("Welcome" + AdminUser);
Console.WriteLine("What would you like to do?");
Console.WriteLine("1.View normal user records.");
Console.WriteLine("2.View Administrator user records.");
Console.WriteLine("3.View log files.");
Console.WriteLine("");
Console.WriteLine("");
Console.WriteLine("");
Console.WriteLine("");
Console.WriteLine("");
break;
default:
Console.WriteLine("Invalid choice, please enter a valid number.");
break;
};
}
// Catch invalid keys such as spamming enter
catch
{
MainMenu = false;
};
}
}
}
}

View File

@ -0,0 +1,55 @@
using System;
using Microsoft.Data.SqlClient;
using TeamHobby.HobbyProjectGenerator;
using TeamHobby.HobbyProjectGenerator.DAL;
using TeamHobby.HobbyProjectGenerator.Models;
namespace TeamHobby.HobbyProjectGenerator.Main
{
public class ExampleDAO
{
public void UserData(string username)
{
// Sql server connection string, needs to be changed accordingly to connect
var connString = "server=localhost,3316;user=root;database=users;password=Plop20"; // Using @" " makes the string literal
// ADO.NET - ODBC
using var conn = new SqlConnection(connString);
{
// More complex sql commands are done in this method instead
var sql = "Select * from roles";
using (var command = new SqlCommand(sql, conn))
{
conn.Open();
// Get the results from the query
SqlDataReader r = command.ExecuteReader();
// If you wanted to get a singular value back such as a count of a certain item
//command.ExecuteScalar();
// To execute something that doesn't expect results to come back
// Use this method instead, IE. Update command
//command.ExecuteNonQuery();
// Read data from query
while (r.Read())
{
Console.WriteLine(r.ToString());
}
conn.Close();
}
// Console.Read();
/*
* this is meant for specific basic sql commands
using (var adapter = new SqlDataAdapter())
{
adapter.SelectCommand
}
*/
//return null;
}
}
}
}

View File

@ -0,0 +1,134 @@
using System;
namespace TeamHobby.HobbyProjectGenerator.Main
{
public class MainMenu
{
static void Main(string[] args)
{
/* ExampleDAO z = new ExampleDAO();
z.UserData("Tomato");
Console.Read();*/
bool menu = true;
// Set up menu loop
while (menu == true)
{
// Console customization
// Change the look of the console
Console.Title = "HobbyProjectGenerator";
// Change console text color
Console.ForegroundColor = ConsoleColor.Green;
// Change terminal height
Console.WindowHeight = 40;
// Create intial menu
Console.WriteLine("What would you like to do?");
int num = 1;
Console.WriteLine(num + ".Create a new user account.");
num += 1;
Console.WriteLine(num + ".Acess Admin Features.");
// Set up try-catch for invalid inputs
try
{
// Get user choice
string initialChoice = Console.ReadLine();
// Convert to integer
int Choice = Convert.ToInt32(initialChoice);
switch (Choice)
{
// Create a new account
case 1:
// Get username
Console.WriteLine("Please enter a username:");
string userName = Console.ReadLine();
// Get Password
Console.WriteLine("Please enter a password:");
string userPassword = Console.ReadLine();
// Create bool value for password confirm loop
bool conPsswrd = true;
// Loop until password is confirmed
while (conPsswrd == true)
{
// Confirm Password
Console.WriteLine("Please re-enter the password:");
string checkPsswd = Console.ReadLine();
// Check if passwords match
if (userPassword == checkPsswd)
{
// Get Security question for password reset
Console.WriteLine("Please enter a security question.\n" +
"(EX: What is your favorite food?");
string SecQuest = Console.ReadLine();
// Get Security question answer
Console.WriteLine("Please enter the answer for your security question:");
String SecAnswer = Console.ReadLine();
// Call user manager method to create the new user
//int userCreateConfirm = new CreateUser(userName,userPassword,SecQuest,SecAnswer);
// Check if user creation was successful
/* if (userCreateConfirm = 1)
{
// Confirm to user that the account has been created
Console.WriteLine("Account created succesfully with the username of" + userName);
}
else
{
}*/
conPsswrd = false;
}
else
{
Console.WriteLine("Passwords did not match, please try again.");
}
}
break;
// Access Admin features
case 2:
// Ask for Admin login credentials
Console.WriteLine("Please enter a username:");
string AdminUser = Console.ReadLine();
Console.WriteLine("Please enter the password for" + AdminUser);
string AdminPsswrd = Console.ReadLine();
// Check if the username and password match a record within the administrators
// Show new administrator menu
int AdminNum = 0;
Console.WriteLine("Welcome" + AdminUser);
Console.WriteLine("What would you like to do?");
Console.WriteLine("1.View normal user records.");
Console.WriteLine("2.View Administrator user records.");
Console.WriteLine("3.");
Console.WriteLine("");
Console.WriteLine("");
Console.WriteLine("");
Console.WriteLine("");
Console.WriteLine("");
break;
default:
menu = false;
break;
};
}
// Catch invalid keys such as spamming enter
catch
{
menu = false;
};
}
}
}
}

View File

@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace main
{
internal class SystemAccountManager
{
public void AccountController()
{
// Create objects
UserAccount user = new UserAccount();
UiPrint ui = new UiPrint();
bool foo = true;
while (foo == true)
{
// sub menu
ui.SystemAccountMenu();
//
}
}
}
}

View File

@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
// Print Statements used throughout the program.
namespace main
{
internal class UiPrint
{
public void InitialMenu()
{
// Create intial menu
Console.WriteLine("What would you like to access?");
int num = 1;
Console.WriteLine(num + ".User Management");
num += 1;
Console.WriteLine(num + ".Logging");
}
public void SystemAccountMenu()
{
// Create intial menu
Console.WriteLine("What would you like to do?");
int num = 1;
Console.WriteLine(num + ".Create a new account.");
num += 1;
Console.WriteLine(num + ".Access Admin Features");
}
}
}

View File

@ -0,0 +1,34 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace main
{
public class UserAccount
{
private string username;
private string password;
private string role;
public UserAccount(string un,string pwd,string rol)
{
username = un;
password = pwd;
role = rol;
}
public UserAccount()
{
password = "1234";
role = "Regular";
}
public void newUser()
{
}
}
}

View File

@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>