//MAIN MENU METHOD - Level 1.0 #region MAIN MENU public string MainMenu(List <string> userMenu, string username, string password, int accessLevel) { while (true) { string selectedMenuItem2 = Menu.MenuRun(userMenu, username, accessLevel); DBManipulateUser du = new DBManipulateUser(); //USER MODULES - LEVEL 2 #region USER MODULES #region Send Mail if (selectedMenuItem2 == "Send Mail") { Console.Clear(); DBPrintUsers pu = new DBPrintUsers(); UsersMessages umm = new UsersMessages(); var listOfUsersString = pu.DBUsersPrintString(username); Console.Clear(); umm.MessagesUserPrint(listOfUsersString, username, password, AccessLevel); } #endregion #region Change Password else if (selectedMenuItem2 == "Change Password") { Console.Clear(); Console.WriteLine("Change User's Password"); Console.WriteLine(); Console.Write($"Please Enter your new Password {username}: "); string newPassword = Console.ReadLine().Trim(); string actionString = "Update dbo.Users set Password = @Password where Username = @Username"; du.DBUserManipulate(username, "change Password", actionString, username, password, username, newPassword); } #endregion #region Read Mail //else if (selectedMenuItem2 == "Read Mail") //{ // Console.Clear(); // Console.WriteLine("New Username: "******"New Password: "******"Users Manipulation") { Console.Clear(); UsersActions ua = new UsersActions(); ua.ActionsUsers(superMenu, username, password, accessLevel); } #endregion #region Users Messages Manipulation Menu //else if (selectedMenuItem2 == "Users Messages Manipulation") //{ // Console.Clear(); // UsersActions ua = new UsersActions(); // ua.ActionsUsers(messagesManipulationMenu, username, password, accessLevel); //} #endregion #region Message Manipulation Admin else if (selectedMenuItem2 == "Edit Users Messages") { Console.Clear(); DBPrintUsers pu = new DBPrintUsers(); UsersMessagesMenu umm = new UsersMessagesMenu(); var listOfUsersString = pu.DBUsersPrintString(username); Console.Clear(); string actionString = "Update dbo.Messages set Message = @newMessage where MessageID = @MessageID"; umm.MenuUserMessages(listOfUsersString, username, password, AccessLevel, "update message", actionString); } else if (selectedMenuItem2 == "Delete Users Messages") { Console.Clear(); DBPrintUsers pu = new DBPrintUsers(); UsersMessagesMenu umm = new UsersMessagesMenu(); var listOfUsersString = pu.DBUsersPrintString(username); Console.Clear(); string actionString = "delete From dbo.Messages where MessageID = @MessageID"; umm.MenuUserMessages(listOfUsersString, username, password, AccessLevel, "delete", actionString); } #endregion #region ADMIN USER MENU else if (selectedMenuItem2 == "Users") { Console.Clear(); MenuCall(adminUsersMenu); } #endregion #region Print Users else if (selectedMenuItem2 == "Print Users") { DBPrintUsers pu = new DBPrintUsers(); pu.Printusers(); var listOfUsersString = pu.DBUsersPrintString(username); Console.Clear(); MainMenu(listOfUsersString, Username, Password, accessLevel); } #endregion #region Users Messages else if (selectedMenuItem2 == "View Users Messages") { Console.Clear(); Console.WriteLine("VIEW USERS MESSAGES"); Console.WriteLine(""); DBPrintUsers pu = new DBPrintUsers(); UsersMessages umm = new UsersMessages(); var listOfUsersString = pu.DBUsersPrintString(username); umm.UsersMessagesPrint(listOfUsersString, username, password, AccessLevel); Console.Clear(); } #endregion #endregion //SUPER ADMIN MODULES - LEVEL 4 #region SUPER ADMIN MODULES #region Delete User else if (selectedMenuItem2 == "Delete User") { Console.Clear(); Console.CursorVisible = true; Console.WriteLine("DELETE USER"); Console.WriteLine(); #region DELETE USERNAME INPUT Console.Write("Which User should I Delete for you SuperAdmin: "); string deleteUser = Console.ReadLine().Trim(); DBCheckUser dbc = new DBCheckUser(deleteUser); bool Verify = true; Verify = dbc.DBUserCheck(deleteUser); int i = 0; while ((Verify == false || deleteUser.Length < 1) && i < 2) { i++; Console.Clear(); Console.WriteLine("LOGIN"); Console.WriteLine(); Console.WriteLine($"Username does not Exist. Try another one ({3 - i} more tries):"); Console.Write("Username: "******"delete From dbo.Users where Username = @Username"; dbdu.DBUserManipulate(deleteUser, "delete", actionString, username, password, "", ""); //(deleteUser, username, password, actionString); #endregion } #endregion #endregion #region Update User //else if (selectedMenuItem2 == "Update User") //{ // Console.Clear(); // Console.CursorVisible = true; // Console.WriteLine("Update USER"); // Console.WriteLine(); // #region DELETE USERNAME INPUT // Console.Write("Which User should I Update for you SuperAdmin: "); // string updateUser = Console.ReadLine().Trim(); // DBCheckUser dbc = new DBCheckUser(updateUser); // bool Verify = true; // Verify = dbc.DBUserCheck(updateUser); // int i = 0; // while ((Verify == false || updateUser.Length < 1) && i < 2) // { // i++; // Console.Clear(); // Console.WriteLine("LOGIN"); // Console.WriteLine(); // Console.WriteLine($"Username does not Exist. Try another one ({3 - i} more tries):"); // Console.Write("Username: "******"Create New User") //Adds user to database { Console.Clear(); Console.WriteLine("NEW USER"); Console.CursorVisible = true; Console.Write("New Username: "******"NEW USER SIGNUP"); Console.WriteLine(); Console.WriteLine($"Username is Taken. Try another one ({3 - i} more tries):"); Console.Write("Username: "******"New Password: "******"Confirm New Password: "******"Passwords did not Confirm. {2 - j} tries left. Try again:"); Console.Write("New Password: "******"Confirm New Password: "******""); j++; } Console.Clear(); if (NewPassword == NewPassword2) { AddUser c = new AddUser(NewUsername, NewPassword); AddUser.DBUserAdd(NewUsername, NewPassword); Console.WriteLine($"New User Created with Username: {NewUsername}"); Console.Write($"Press any key to Continue.."); Console.ReadKey(); Console.CursorVisible = false; } } #endregion #region Change User Role else if (selectedMenuItem2 == "Change User Role") { Console.Clear(); Console.WriteLine("USER ROLES"); Console.WriteLine(""); DBPrintUsers pu = new DBPrintUsers(); AssignRoles ar = new AssignRoles(); var listOfUsersString = pu.DBUsersPrintString(username); ar.UserRoles(listOfUsersString, username, password, AccessLevel); Console.Clear(); } #endregion #endregion #region Main Menu else if (selectedMenuItem2 == "Main Menu") { Console.Clear(); AccessLevelCheck alc = new AccessLevelCheck(Username, Password); //, true, true); alc.LevelMenuCall(Username, Password); //MainMenu(superAdminMenu, Username, Password); } #endregion //#endregion //UNIVERSAL MODULES - LEVEL ALL #region UNIVERSAL MODULES #region Logout else if (selectedMenuItem2 == "Logout") { Console.Clear(); MenuCall(); } #endregion #region Exit else if (selectedMenuItem2 == "Exit") { Environment.Exit(0); } #endregion #endregion Console.Clear(); } }
public void ActionsUsers(List <string> superMenu, string username, string password, int accessLevel) { DBManipulateUser du = new DBManipulateUser(); DATABASE_CS.DBPrintUsers pu = new DATABASE_CS.DBPrintUsers(); List <string> listOfUsersString = pu.DBUsersPrintString(username); string changeUsername = (Menu.MenuRun(listOfUsersString, username, accessLevel)).Trim(); Console.Clear(); string SuperMenuItem = (Menu.MenuRun(superMenu, username, accessLevel)).Trim(); string newUsername = ""; string newPassword = ""; if (SuperMenuItem == "Delete User") { string actionString = "delete from dbo.Users where Username = @Username; delete from dbo.Messages where Sender = @Username or Receiver = @Username;"; du.DBUserManipulate(changeUsername, "delete", actionString, username, password, newUsername, newPassword); } else if (SuperMenuItem == "Change User's Password") { Console.Clear(); Console.WriteLine("Change User's Password"); Console.WriteLine(); Console.CursorVisible = true; Console.WriteLine($"Please Enter new Password for user {changeUsername}: "); newPassword = Console.ReadLine().Trim(); Console.CursorVisible = false; string actionString = "Update dbo.Users set Password = @Password where Username = @Username"; du.DBUserManipulate(changeUsername, "change Password", actionString, username, password, newUsername, newPassword); } else if (SuperMenuItem == "Change User Role") { Console.Clear(); Console.WriteLine("USER ROLES"); Console.WriteLine(""); DBPrintUsers pu2 = new DBPrintUsers(); AssignRoles ar = new AssignRoles(); SuperMenuItem = pu2.DBUsersPrintString(username).ToString(); ar.UserRoles(listOfUsersString, username, password, accessLevel); Console.Clear(); } else if (SuperMenuItem == "Change User's Username") { Console.Clear(); Console.WriteLine("Change User's Username"); Console.WriteLine(); Console.CursorVisible = true; Console.WriteLine($"Please Enter new Username for user {changeUsername}: "); newUsername = Console.ReadLine().Trim(); Console.CursorVisible = false; bool Verify = false; DBCheckUser dbc = new DBCheckUser(); Verify = dbc.DBUserCheck(newUsername); int i = 0; while ((Verify == true || newUsername.Length < 1) && i < 2) { i++; Console.Clear(); Console.WriteLine("LOGIN"); Console.WriteLine(); Console.WriteLine($"Username <<{newUsername}>> Exist. Try another one ({3 - i} more tries):"); Console.CursorVisible = true; Console.Write("Username: "******"End of Tries!! \n Press any key to continue..."); Console.ReadKey(); Console.CursorVisible = false; alc.LevelMenuCall(username, password); } } string actionString = "Update dbo.Users set Username = @NewUsername where Username = @Username; Update dbo.Messages set Sender = @NewUsername where Sender = @Username; Update dbo.Messages set Receiver = @NewUsername where Receiver = @Username;"; du.DBUserManipulate(changeUsername, "change Username", actionString, username, password, newUsername, newPassword); } }