public void ViewMessages() { Console.Clear(); var messages = MessageRepository.GetMessages(); if (messages.Count == 0) { Various.SystemMessage("No messages"); System.Threading.Thread.Sleep(1500); return; } MenuDesigner MessageMenu = new MenuDesigner(messages, $"{UserRepository.currentUser.Username} : View Messages"); int messageViewChoice = MessageMenu.MenuDesignMessage(out int correctMessageId); if (correctMessageId < 0) { return; } Console.Clear(); Various.Header($"{UserRepository.currentUser.Username} : View Messages"); Console.WriteLine(MessageRepository.ViewMessage(correctMessageId)); LogRepository.TypeInLog($"{UserRepository.currentUser.Username}", "viewed message"); Console.WriteLine(); Various.SystemMessage("Press any key to exit"); Console.ReadKey(); }
public void PickTwoUsers(string operation, out int senderId, out int receiverId) { Console.Clear(); Various.Header($"{UserRepository.currentUser.Username} : {operation}"); Console.WriteLine(); Various.SystemMessageDirections("Pick two user ids so you can see the messages between them"); ViewAllUsers(); Console.WriteLine(); int userId1 = PickUserExtended(); if (userId1 == -1) { senderId = -1; receiverId = -1; return; } int userId2 = PickUserExtended(); if (userId2 == -1) { senderId = -1; receiverId = -1; return; } senderId = userId1; receiverId = userId2; }
public int DeleteUserPick() { Console.Clear(); Various.Header($"{UserRepository.currentUser.Username} : Delete User"); ViewUsersExtended(); Console.WriteLine(); int userId = PickUser(); if (userId == -1) { return(-1); } Console.Write("Are you sure? (Y/N): "); string yesOrNo = Various.TypeLetterByLetterWithoutMaskingYesOrNoSTR(); if (yesOrNo == "Y" || yesOrNo == "y") { return(userId); } else { return(-1); } }
public string UsernameMenu() { Console.Write("Username: "); string registerUsername = Various.TypeLetterByLetterWithoutMasking(); return(registerUsername); }
public string PasswordMenu() { Console.Write("Password: "); string registerPassword = Various.TypeLetterByLetterWithMasking(); return(registerPassword); }
// Type the message public void TypeMessage() { int receiverId = SelectUser(); if (receiverId < 0) { return; } User Receiver = new User(); using (var db = new myContext()) { Receiver = db.Users.Find(receiverId); } Console.Clear(); Various.Header($"{ UserRepository.currentUser.Username} : Send Message to {Receiver.Username}"); string title; string body; // Title Various.SystemMessageDirections("Title must be max 15 characters long"); Console.Write("Type the title of the message: "); title = Various.TypeLetterByLetterWithoutMaskingSTR(15); // Checks if Esc is pressed if (title == "") { Console.WriteLine(); Various.SystemMessage("Send Message Failed"); System.Threading.Thread.Sleep(1500); return; } // Body Console.WriteLine(); Console.WriteLine(); Various.SystemMessageDirections("Body must be max 250 characters long"); Console.Write("Type the body of the message: "); body = Various.TypeLetterByLetterWithoutMaskingSTR(249); // Checks if Esc is pressed if (body == "") { Console.WriteLine(); Various.SystemMessage("Send Message Failed"); System.Threading.Thread.Sleep(1500); return; } MessageRepository.SendMessage(title, body, receiverId); LogRepository.TypeInLog($"{UserRepository.currentUser.Username}", "sent message"); Console.WriteLine(); Various.SystemMessageSuccess("Message Sent Successful"); System.Threading.Thread.Sleep(1500); return; }
public int PickAMessageBetweenTwoUsers(List <Message> messages) { if (messages.Count == 0) { Console.WriteLine(); Various.SystemMessage("There are no messages"); System.Threading.Thread.Sleep(1500); return(-1); } Console.Clear(); MenuDesigner MessageMenu = new MenuDesigner(messages, $"{UserRepository.currentUser.Username} : Edit Message"); int messageViewChoice = MessageMenu.MenuDesignMessage(out int correctMessageId); return(correctMessageId); }
public void DeleteMessageBetweenTwoUsers(string operation) { TierMenu.PickTwoUsers(operation, out int senderId, out int receiverId); List<Message> messages = MessageRepository.GetMessageBetweenTwoUsers(senderId, receiverId); if (senderId < 0 || receiverId < 0) { Console.WriteLine(); Various.SystemMessage("Delete Message Between Two Users Failed"); System.Threading.Thread.Sleep(1500); return; } TierMenu.DeleteAMessageBetweenTwoUsers(messages); LogRepository.TypeInLog($"{UserRepository.currentUser.Username}", "deleted message between two users"); }
// Menu Design public int MenuDesign() { do { Console.Clear(); Various.Header(CurrentLogo); for (i = 0; i < MenuItems.Count; i++) { if (CurrentItem == i) { Console.ForegroundColor = ConsoleColor.DarkGreen; Console.WriteLine(MenuItems[i]); Console.ResetColor(); } else { Console.WriteLine(MenuItems[i]); } } pressedKey = Console.ReadKey(true); if (pressedKey.Key.ToString() == "DownArrow") { CurrentItem++; if (CurrentItem > MenuItems.Count - 1) { CurrentItem = 0; } } else if (pressedKey.Key.ToString() == "UpArrow") { CurrentItem--; if (CurrentItem < 0) { CurrentItem = MenuItems.Count - 1; } } else if (pressedKey.Key == ConsoleKey.Escape) { return(-1); } } while (pressedKey.Key != ConsoleKey.Enter); return(CurrentItem); }
public int UpdateUserPick() { Console.Clear(); Various.Header($"{UserRepository.currentUser.Username} : Update User"); ViewUsersExtended(); Console.WriteLine(); int userId = PickUser(); if (userId == -1) { return(-1); } return(userId); }
// Choose userId to send message public int SelectUser() { Console.Clear(); Various.Header($"{UserRepository.currentUser.Username} : Send Message"); ViewUsers(); Console.WriteLine(); int userId = PickUser(); if (userId == -1) { Console.WriteLine(); Various.SystemMessage("SendMessage Failed"); System.Threading.Thread.Sleep(1500); } return(userId); }
public void EditMessageBetweenTwoUsers(string operation) { TierMenu.PickTwoUsers(operation, out int senderId, out int receiverId); List<Message> messages = MessageRepository.GetMessageBetweenTwoUsers(senderId, receiverId); if (senderId < 0 || receiverId < 0) { Console.WriteLine(); Various.SystemMessage("Edit Message Between Two Users Failed"); System.Threading.Thread.Sleep(1500); return; } int choice = TierMenu.PickAMessageBetweenTwoUsers(messages); if (choice < 0) { Console.WriteLine(); Various.SystemMessage("Edit Message Failed"); System.Threading.Thread.Sleep(1500); return; } string edit = TierMenu.TitleOrBodyEdit(choice, out int choiceToEdit); if (choiceToEdit < 0) { Console.WriteLine(); Various.SystemMessage("Edit Message Failed"); System.Threading.Thread.Sleep(1500); return; } else if (choiceToEdit == 0) { MessageRepository.EditMessageTitle(choice, edit); } else if (choiceToEdit == 1) { MessageRepository.EditMessageBody(choice, edit); } LogRepository.TypeInLog($"{UserRepository.currentUser.Username}", "edited message between two users"); Console.WriteLine(); Various.SystemMessageSuccess("Edit Message successfull"); System.Threading.Thread.Sleep(1500); return; }
public void DeleteUser() { int userId = SuperAdminMenu.DeleteUserPick(); if (userId == -1) { Console.WriteLine(); Various.SystemMessage("Delete User failed"); System.Threading.Thread.Sleep(1500); return; } MessageRepository.ChangeIdOfUserToDelete(userId); UserRepository.DeleteUser(userId); LogRepository.TypeInLog($"{UserRepository.currentUser.Username}", $"deleted user"); Console.WriteLine(); Various.SystemMessageSuccess($"User[{userId}] deleted."); System.Threading.Thread.Sleep(1500); }
public void DeleteAMessageBetweenTwoUsers(List <Message> messages) { if (messages.Count == 0) { Console.WriteLine(); Various.SystemMessage("There are no messages"); System.Threading.Thread.Sleep(2000); return; } Console.Clear(); MenuDesigner MessageMenu = new MenuDesigner(messages, $"{UserRepository.currentUser.Username} : Delete Message"); int messageViewChoice = MessageMenu.MenuDesignMessage(out int correctMessageId); if (correctMessageId < 0) { Various.SystemMessage("Delete Message Failed"); System.Threading.Thread.Sleep(2000); return; } Console.Clear(); Various.Header($"{UserRepository.currentUser.Username} : Delete Message"); Console.WriteLine(MessageRepository.ViewMessageWithoutChangingRead(correctMessageId)); Console.WriteLine(); Console.Write("Are you sure? (Y / N): "); string yesOrno = Various.TypeLetterByLetterWithoutMaskingYesOrNoSTR(); if (yesOrno == "y" || yesOrno == "Y") { MessageRepository.DeleteMessage(correctMessageId); Console.WriteLine(); Various.SystemMessageSuccess("Message Deleted"); System.Threading.Thread.Sleep(1500); } else { Console.WriteLine(); Various.SystemMessage("Delete Message failed"); System.Threading.Thread.Sleep(1500); } }
public int PickUserExtended() { User userPicked = null; bool canPass = false; int tries = 0; int userId = 0; do { Console.Write("Select user: "******"This user does not exist"); System.Threading.Thread.Sleep(1500); } tries++; } while ((!canPass && tries < 3) || (!canPass && tries < 3)); if (tries >= 3) { return(-1); } return(userId); }
public void ViewAMessageBetweenTwoUsers(List <Message> messages) { if (messages.Count == 0) { Console.WriteLine(); Various.SystemMessage("There are no messages"); System.Threading.Thread.Sleep(1500); return; } Console.Clear(); MenuDesigner MessageMenu = new MenuDesigner(messages, $"{UserRepository.currentUser.Username} : View Messages Between Two Users"); int messageViewChoice = MessageMenu.MenuDesignMessage(out int correctMessageId); if (correctMessageId < 0) { return; } Console.Clear(); Various.Header($"{UserRepository.currentUser.Username} : View Messages Between Two Users"); Console.WriteLine(MessageRepository.ViewMessageWithoutChangingRead(correctMessageId)); Console.WriteLine(); Various.SystemMessage("Press any key to exit"); Console.ReadKey(); }
public void UpdateUser() { int userId = SuperAdminMenu.UpdateUserPick(); if (userId == -1) { Console.WriteLine(); Various.SystemMessage("Update User failed"); System.Threading.Thread.Sleep(1500); return; } UpdateOptions updateChoice = SuperAdminMenu.UpdateMenu(); switch (updateChoice) { case UpdateOptions.Username: string username = Various.UpdateUsername(); if (username == "") { Console.WriteLine(); Various.SystemMessage("Update Username failed"); System.Threading.Thread.Sleep(1500); return; } UserRepository.UpdateUserUsername(userId, username); LogRepository.TypeInLog($"{UserRepository.currentUser.Username}", "updated username of user"); Various.SystemMessageSuccess("Username updated successfully"); System.Threading.Thread.Sleep(1500); break; case UpdateOptions.Password: string password = Various.UpdatePassword(); if (password == "") { Console.WriteLine(); Various.SystemMessage("Update Password failed"); System.Threading.Thread.Sleep(1500); return; } UserRepository.UpdateUserPassword(userId, password); LogRepository.TypeInLog($"{UserRepository.currentUser.Username}", "updated password of user"); Various.SystemMessageSuccess("Password updated successfully"); System.Threading.Thread.Sleep(1500); break; case UpdateOptions.Role: RoleOptions updatedRoleChoice = SuperAdminMenu.RoleMenu("Update User"); Role role = Role.Tier0User; switch (updatedRoleChoice) { case RoleOptions.Tier3User: role = Role.Tier3User; break; case RoleOptions.Tier2User: role = Role.Tier2User; break; case RoleOptions.Tier1User: role = Role.Tier1User; break; case RoleOptions.Tier0User: role = Role.Tier0User; break; case RoleOptions.Exit: Various.SystemMessage("Update User failed"); System.Threading.Thread.Sleep(1500); return; default: Various.SystemMessage("Update User failed"); System.Threading.Thread.Sleep(1500); return; } UserRepository.UpdateUserRole(userId, role); LogRepository.TypeInLog($"{UserRepository.currentUser.Username}", "updated role of user"); Various.SystemMessageSuccess("Role updated successfully"); System.Threading.Thread.Sleep(1500); break; case UpdateOptions.Exit: return; default: return; } }
public void ViewUserExtended() { SuperAdminMenu.ViewUsersExtended(); Console.WriteLine(); Various.SystemMessage("Press Any Key To Exit"); }
public string TitleOrBodyEdit(int messageToBeEditedId, out int choiceToEdit) { Console.Clear(); List <string> TitleOrBodyMenuItems = new List <string> { "Title", "Body", "Exit" }; MenuDesigner TitleOrBodyMenu = new MenuDesigner(TitleOrBodyMenuItems, $"{UserRepository.currentUser.Username} : Edit Message"); int choice = TitleOrBodyMenu.MenuDesign(); Console.WriteLine(); switch (choice) { case 0: // Title Console.Clear(); Various.Header($"{UserRepository.currentUser.Username} : Edit Message : Edit Title"); string title; Console.WriteLine(MessageRepository.ViewMessageWithoutChangingRead(messageToBeEditedId)); Console.WriteLine(); Various.SystemMessageDirections("Title must be max 15 characters long and cannot be void"); Console.Write("Type the title of the message: "); title = Various.TypeLetterByLetterWithoutMaskingSTR(15); // Checks if Esc is pressed if (title == "") { choiceToEdit = -1; return(""); } choiceToEdit = 0; return(title); case 1: // Body Console.Clear(); Various.Header($"{UserRepository.currentUser.Username} : Edit Message : Edit Body"); string body; Console.WriteLine(MessageRepository.ViewMessageWithoutChangingRead(messageToBeEditedId)); Console.WriteLine(); Various.SystemMessageDirections("Body must be max 250 characters long and cannot be void"); Console.Write("Type the body of the message: "); body = Various.TypeLetterByLetterWithoutMaskingSTR(249); // Checks if Esc is pressed if (body == "") { choiceToEdit = -1; return(""); } choiceToEdit = 1; return(body); case 2: choiceToEdit = -1; return(""); default: choiceToEdit = -1; return(""); } }
// Menu Design For Messages public int MenuDesignMessage(out int correctMessageId) { do { Console.Clear(); Console.CursorVisible = false; Various.Header(CurrentLogo); Console.WriteLine(); Various.SystemMessageDirections("Press [1] to sort by Date descending, [2] to sort by Sender name, [3] to sort by Title or [4] to sort by Unread/Read"); Console.WriteLine(); for (i = 0; i < Messages.Count; i++) { // Length Fix int length = 6; if (Messages[i].Body.Length < 6) { length = Messages[i].Body.Length; } if (CurrentItem == i) { if (Messages[i].Read == false) { Console.BackgroundColor = ConsoleColor.DarkMagenta; Console.ForegroundColor = ConsoleColor.White; Console.WriteLine($"{Messages[i].Date} - From: {Messages[i].Sender.Username} To: {Messages[i].Receiver.Username} - Title: {Messages[i].Title} - Message: {Messages[i].Body.Substring(0,length) + "..."}"); Console.ResetColor(); } else if (Messages[i].Read == true) { Console.BackgroundColor = ConsoleColor.DarkMagenta; Console.ForegroundColor = ConsoleColor.Gray; Console.WriteLine($"{Messages[i].Date} - From: {Messages[i].Sender.Username} To: {Messages[i].Receiver.Username} - Title: {Messages[i].Title} - Message: {Messages[i].Body.Substring(0,length) + "..."}"); Console.ResetColor(); } } else { if (Messages[i].Read == false) { Console.ForegroundColor = ConsoleColor.White; Console.WriteLine($"{Messages[i].Date} - From: {Messages[i].Sender.Username} To: {Messages[i].Receiver.Username} - Title: {Messages[i].Title} - Message: {Messages[i].Body.Substring(0,length) + "..."}"); Console.ResetColor(); } else if (Messages[i].Read == true) { Console.ForegroundColor = ConsoleColor.Gray; Console.WriteLine($"{Messages[i].Date} - From: {Messages[i].Sender.Username} To: {Messages[i].Receiver.Username} - Title: {Messages[i].Title} - Message: {Messages[i].Body.Substring(0,length) + "..."}"); Console.ResetColor(); } } } pressedKey = Console.ReadKey(true); if (pressedKey.Key.ToString() == "DownArrow") { CurrentItem++; if (CurrentItem > Messages.Count - 1) { CurrentItem = 0; } } else if (pressedKey.Key.ToString() == "UpArrow") { CurrentItem--; if (CurrentItem < 0) { CurrentItem = Messages.Count - 1; } } else if (pressedKey.Key == ConsoleKey.Escape) { correctMessageId = -1; return(-1); } else if (pressedKey.KeyChar.ToString() == "1") { Messages = Messages.OrderByDescending(x => x.Date).ToList(); } else if (pressedKey.KeyChar.ToString() == "2") { Messages = Messages.OrderBy(x => x.Sender.Username).ToList(); } else if (pressedKey.KeyChar.ToString() == "3") { Messages = Messages.OrderBy(x => x.Title).ToList(); } else if (pressedKey.KeyChar.ToString() == "4") { Messages = Messages.OrderBy(x => x.Read).ToList(); } } while (pressedKey.Key != ConsoleKey.Enter); correctMessageId = Messages[CurrentItem].Id; return(CurrentItem); }
static void Main(string[] args) { Console.CursorVisible = false; Menus Menu = new Menus(); UserRepository UserRepository = UserRepository.Instance; LogRepository LogRepository = new LogRepository(); LogRepository.TypeInLog("Application", "started"); do { try { do { MainMenuOptions mainMenuChoice = Menu.MainMenu(); switch (mainMenuChoice) { case MainMenuOptions.Login: #region Login Console.Clear(); Various.Header("Login"); bool usernameExists; bool correctPasswordLength; bool usernameMatchesPassword; int tries = 0; string loginUsername; string loginPassword; // Username Check do { loginUsername = Menu.UsernameMenu(); usernameExists = UserRepository.UsernameExists(loginUsername); tries++; if (usernameExists == false && tries < 3) { Console.WriteLine(); Various.SystemMessage("Username does not exist"); } } while (usernameExists == false && tries < 3); if (tries >= 3 && usernameExists == false) { Console.WriteLine(); Various.SystemMessage("Login failed"); System.Threading.Thread.Sleep(1500); break; } else { Console.Write(" "); Various.SystemMessageSuccess("OK"); } // Password Check tries = 0; do { loginPassword = Menu.PasswordMenu(); usernameMatchesPassword = UserRepository.UsernameAndPasswordMatch(loginUsername, loginPassword); correctPasswordLength = UserRepository.CorrectPasswordLength(loginPassword); tries++; if (correctPasswordLength == false && tries < 3) { Console.WriteLine(); Various.SystemMessage("Password must be between 5 and 12 characters"); } if (usernameMatchesPassword == false && correctPasswordLength == true && tries < 3) { Console.WriteLine(); Various.SystemMessage("Wrong password"); } } while (correctPasswordLength == false && usernameMatchesPassword == false && tries < 3 || correctPasswordLength == true && usernameMatchesPassword == false && tries < 3); if (tries >= 3 && correctPasswordLength == false || tries >= 3 && usernameMatchesPassword == false) { Console.WriteLine(); Various.SystemMessage("Login failed"); System.Threading.Thread.Sleep(1500); break; } else { Console.Write(" "); Various.SystemMessageSuccess("OK"); UserRepository.AssignCurrentUser(loginUsername, loginPassword); LogRepository.TypeInLog(UserRepository.currentUser.Username, "logged in"); Various.SystemMessageSuccess("Logged in successfully"); System.Threading.Thread.Sleep(1500); } // Role Choose switch (UserRepository.currentUser.Role) { case Role.SuperAdmin: #region SuperAdmin SuperAdminLoggedIn sa = new SuperAdminLoggedIn(); bool superAdminExit = false; do { SuperAdminOptions superAdminOption = Menu.SuperAdminMenu(); switch (superAdminOption) { case SuperAdminOptions.CreateUser: sa.AdminCreateUser(); break; case SuperAdminOptions.DeleteUser: sa.DeleteUser(); break; case SuperAdminOptions.UpdateUser: sa.UpdateUser(); break; case SuperAdminOptions.ViewUsers: Console.Clear(); Various.Header($"{ UserRepository.currentUser.Username} : View Users"); sa.ViewUserExtended(); Console.ReadKey(); break; case SuperAdminOptions.SendMessage: Menu.TypeMessage(); break; case SuperAdminOptions.ViewMessages: Menu.ViewMessages(); break; case SuperAdminOptions.Exit: superAdminExit = true; break; default: break; } } while (!superAdminExit); #endregion break; case Role.Tier3User: #region Tier3User Tier123UserLoggedIn Tier3User = new Tier123UserLoggedIn(); bool tier3UserExit = false; do { Tier3UserOptions Tier3option = Menu.Tier3UserMenu(); switch (Tier3option) { case Tier3UserOptions.EditMessage: Tier3User.EditMessageBetweenTwoUsers("Edit Message Between Two Users"); break; case Tier3UserOptions.DeleteMessage: Tier3User.DeleteMessageBetweenTwoUsers("Delete Message Between Two Users"); break; case Tier3UserOptions.ViewMessage: Tier3User.ChooseMessageBetweenTwoUsers("View Message Between Two Users"); break; case Tier3UserOptions.SendMessage: Menu.TypeMessage(); break; case Tier3UserOptions.ViewMessages: Menu.ViewMessages(); break; case Tier3UserOptions.Exit: tier3UserExit = true; break; default: break; } } while (!tier3UserExit); #endregion break; case Role.Tier2User: #region Tier2User Tier123UserLoggedIn Tier2User = new Tier123UserLoggedIn(); bool Tier2UserExit = false; do { Tier2UserOptions Tier2Option = Menu.Tier2UserMenu(); switch (Tier2Option) { case Tier2UserOptions.EditMessage: Tier2User.EditMessageBetweenTwoUsers("Edit Message Between Two Users"); break; case Tier2UserOptions.ViewMessage: Tier2User.ChooseMessageBetweenTwoUsers("View Message Between Two Users"); break; case Tier2UserOptions.SendeMessage: Menu.TypeMessage(); break; case Tier2UserOptions.ViewMessages: Menu.ViewMessages(); break; case Tier2UserOptions.Exit: Tier2UserExit = true; break; default: break; } } while (!Tier2UserExit); #endregion break; case Role.Tier1User: #region Tier1User Tier123UserLoggedIn Tier1User = new Tier123UserLoggedIn(); bool Tier1UserExit = false; do { Tier1UserOptions Tier1Option = Menu.Tier1UserMenu(); switch (Tier1Option) { case Tier1UserOptions.ViewMessage: Tier1User.ChooseMessageBetweenTwoUsers("View Message Between Two Users"); break; case Tier1UserOptions.SendMessage: Menu.TypeMessage(); break; case Tier1UserOptions.ViewMessages: Menu.ViewMessages(); break; case Tier1UserOptions.Exit: Tier1UserExit = true; break; default: break; } } while (!Tier1UserExit); #endregion break; case Role.Tier0User: #region Tier0User Tier123UserLoggedIn Tier0User = new Tier123UserLoggedIn(); bool Tier0UserExit = false; do { Tier0UserOptions Tier0Option = Menu.Tier0UserMenu(); switch (Tier0Option) { case Tier0UserOptions.SendMessage: Menu.TypeMessage(); break; case Tier0UserOptions.ViewMessages: Menu.ViewMessages(); break; case Tier0UserOptions.Exit: Tier0UserExit = true; break; default: break; } } while (!Tier0UserExit); #endregion break; default: break; } LogRepository.TypeInLog($"{UserRepository.currentUser.Username}", "logged out"); UserRepository.NullCurrentUser(); #endregion break; case MainMenuOptions.Register: #region Register Console.Clear(); Various.Header("Register"); //bool usernameExists; tries = 0; string registerUsername; string registerPassword; // Username Check do { registerUsername = Menu.UsernameMenu(); usernameExists = UserRepository.UsernameExists(registerUsername); tries++; if (usernameExists == true && tries < 3) { Console.WriteLine(); Various.SystemMessage("Username already exists"); } } while (usernameExists == true && tries < 3); if (tries >= 3 && usernameExists == true) { Console.WriteLine(); Various.SystemMessage("Registration failed"); System.Threading.Thread.Sleep(2000); break; } else { Console.Write(" "); Various.SystemMessageSuccess("OK"); } // Password Check tries = 0; do { registerPassword = Menu.PasswordMenu(); correctPasswordLength = UserRepository.CorrectPasswordLength(registerPassword); tries++; if (correctPasswordLength == false && tries < 3) { Console.WriteLine(); Various.SystemMessage("Password must be between 5 and 12 characters"); } } while (correctPasswordLength == false && tries < 3); if (tries >= 3 && correctPasswordLength == false) { Console.WriteLine(); Various.SystemMessage("Registration failed"); System.Threading.Thread.Sleep(2000); break; } else { Console.Write(" "); Various.SystemMessageSuccess("OK"); UserRepository.CreateUserSimple(registerUsername, registerPassword); LogRepository.TypeInLog($"{registerUsername}", "registered"); Various.SystemMessageSuccess("Registration successfull"); System.Threading.Thread.Sleep(2000); } UserRepository.NullCurrentUser(); #endregion break; case MainMenuOptions.Exit: #region Exit Console.Clear(); Various.SystemMessage("GoodBye"); System.Threading.Thread.Sleep(1500); LogRepository.TypeInLog("Application", "exited"); Environment.Exit(0); #endregion break; default: break; } } while (true); } catch (Exception e) { UserRepository.NullCurrentUser(); LogRepository.TypeInLog($"Error: {e.Message}", "occured"); Various.SystemMessageError("An error has occured. We are sorry"); } } while (true); }
public void AdminCreateUser() { Console.Clear(); Various.Header($"{UserRepository.currentUser.Username} : Create User"); RoleOptions roleOption; Role role = Role.Tier0User; // Username string username = Various.UpdateUsername(); if (username == "") { Console.WriteLine(); Various.SystemMessage("Create User failed"); System.Threading.Thread.Sleep(1500); return; } // Password string password = Various.UpdatePassword(); if (password == "") { Console.WriteLine(); Various.SystemMessage("Create User failed"); System.Threading.Thread.Sleep(1500); return; } // Role Assignment roleOption = SuperAdminMenu.RoleMenu("Create User"); switch (roleOption) { case RoleOptions.Tier3User: role = Role.Tier3User; break; case RoleOptions.Tier2User: role = Role.Tier2User; break; case RoleOptions.Tier1User: role = Role.Tier1User; break; case RoleOptions.Tier0User: role = Role.Tier0User; break; case RoleOptions.Exit: Console.WriteLine(); Various.SystemMessage("Create User failed"); System.Threading.Thread.Sleep(1500); return; default: return; } UserRepository.CreateUserExtended(username, password, role); LogRepository.TypeInLog($"{UserRepository.currentUser.Username}", "created user"); Various.SystemMessageSuccess("Create User successfull"); System.Threading.Thread.Sleep(1500); }