public static User AdminSelectsUser() { List <User> UsersList = DataProvider.ReadUserData(); List <string> UsernameList = UsersList.Skip(1).Select(UserInList => UserInList.Username).ToList(); return(UsersList[SelectMenu.Vertical(UsernameList).IndexOfChoice]); }
private ForumMessage ChooseMessageToChange() { List <ForumMessage> MyForumMessages = GetMyMessages(); // Choose which message to change int SelectedMessage = SelectMenu.Vertical(MyForumMessages .Select(Messages => Messages.TextMessageToAll) .ToList()) .IndexOfChoice; // Find the message object return(MyForumMessages[SelectedMessage]); }
internal void ShowPersonalMenu(User ActiveUser, IDataHandler dataHandler) { PersonalMessageActions PersonalMessageAction = new PersonalMessageActions(dataHandler, ActiveUser); MainActions MA = new MainActions(dataHandler); string UserChoice = SelectMenu.Vertical(new List <string> { CREATE_MESSAGE, SHOW_RECEIVED_MESSAGES + PersonalMessageAction.CountUnreadReceived(), SHOW_SENT_MESSAGES + PersonalMessageAction.CountUnreadSent(), CHECK_IF_MESSAGE_READ, EDIT_MESSAGE, DELETE_MESSAGE, BACK }).NameOfChoice; if (UserChoice.Contains(SHOW_RECEIVED_MESSAGES)) { PersonalMessageAction.ShowReceivedMessages(); } else if (UserChoice.Contains(SHOW_SENT_MESSAGES)) { PersonalMessageAction.ShowSentMessages(); } else { switch (UserChoice) { case CREATE_MESSAGE: PersonalMessageAction.CreateMessage(); break; case CHECK_IF_MESSAGE_READ: PersonalMessageAction.IsMessageRead(); break; case EDIT_MESSAGE: PersonalMessageAction.UpdateMessage(); break; case DELETE_MESSAGE: PersonalMessageAction.DeleteMessage(); break; case BACK: MA.Showmenu(ActiveUser.TypeOfUser); break; } } }
public PersonalMessage GetWantedMessage(User ActiveUser) { string ReceivedOrSent = SelectMenu.Horizontal(new List <string> { RECEIVED, SENT }).NameOfChoice; List <PersonalMessage> MessagesToShow = GetMessages(ReceivedOrSent == SENT); int SelectedMessage = SelectMenu.Vertical(MessagesToShow .Select(MessageObject => MessageObject.PersonalMessageText) .ToList()) .IndexOfChoice; return(MessagesToShow[SelectedMessage]); }
public bool ShowSentMessages() { List <PersonalMessage> SentMessages = GetMessages(); List <string> SentPersonalTitles = PresentTitles(SentMessages); int ChosenTitle = SelectMenu.Vertical(SentPersonalTitles).IndexOfChoice; PersonalMessage MessageToShow = SentMessages[ChosenTitle]; Console.WriteLine($"{MessageToShow.TitleText}"); Console.WriteLine($"{MessageToShow.Sender.Username} έστειλες μήνυμα στις " + $"{MessageToShow.SendDate}: {MessageToShow.PersonalMessageText}"); Console.ReadKey(); return(true); }
public string Showmenu(UserType TypeUser) { List <string> MainMenu = new List <string> { FORUM, LOGOUT, EXIT }; if (TypeUser != UserType.Guest) { MainMenu.Insert(1, PERSONAL_MESSAGES); MainMenu.Insert(2, MANAGE_USERS); } return(SelectMenu.Vertical(MainMenu).NameOfChoice); }
public bool ShowReceivedMessages() { List <PersonalMessage> ReceivedPersonalMessages = GetMessages(Sent: false); List <string> ReceivedPersonalTitles = PresentTitles(ReceivedPersonalMessages); int ChosenTitle = SelectMenu.Vertical(ReceivedPersonalTitles).IndexOfChoice; PersonalMessage MessageToShow = ReceivedPersonalMessages[ChosenTitle]; Console.WriteLine($"Ο χρήστης {MessageToShow.Sender.Username} σας έστειλε μήνυμα στις " + $"{MessageToShow.SendDate}: {MessageToShow.PersonalMessageText}"); Debug.Write(DataHandler.MarkMessageAsRead(MessageToShow)); Console.ReadKey(); return(true); }
internal void ShowManageUserMenu(User ActiveUser, IDataHandler dataHandler) { ManageUser MU = new ManageUser(dataHandler, ActiveUser); List <string> Options = new List <string> { UPDATE_USERNAME, UPDATE_PASSWORD, BACK }; if (ActiveUser.TypeOfUser == UserType.Administrator) { Options.Insert(0, UPDATE_USER_ACCESS); Options.Insert(1, DELETE_USER); } while (true) { string Selection = SelectMenu.Vertical(Options).NameOfChoice; switch (Selection) { case UPDATE_USER_ACCESS: MU.UpdateUserAccess(); break; case DELETE_USER: MU.DeleteUser(); break; case UPDATE_USERNAME: MU.UpdateUsername(); break; case UPDATE_PASSWORD: MU.UpdatePassword(); break; default: return; } } }
internal void ShowForumMenu(IDataHandler DataHandler, User ActiveUser) { string UserSelection = SelectMenu.Vertical(new List <string> { ALL_MESSAGES, MY_MESSAGES, NEW_MESSAGE, EDIT_MESSAGE, DELETE_MESSAGE, BACK }).NameOfChoice; ForumActions ForumAction = new ForumActions(DataHandler, ActiveUser); MainActions MA = new MainActions(DataHandler); switch (UserSelection) { case ALL_MESSAGES: ForumAction.ShowAllMessages(); break; case MY_MESSAGES: ForumAction.ShowMyMessages(); break; case NEW_MESSAGE: ForumAction.CreateMessage(); break; case EDIT_MESSAGE: ForumAction.UpdateMessage(); break; case DELETE_MESSAGE: ForumAction.DeleteMessage(); break; case BACK: MA.Showmenu(ActiveUser.TypeOfUser); break; } }
public bool DeleteUser() { SpecificUserActions SUA = new SpecificUserActions(); User SelectedUser = MainActions.AdminSelectsUser(); string UpdateSelection = SelectMenu.Horizontal(new List <string> { DELETE_USER, BACK }).NameOfChoice; switch (UpdateSelection) { case DELETE_USER: default: return(DataProvider.DeleteUser(SelectedUser)); case BACK: return(false); } }
public bool IsMessageRead() { Console.WriteLine("Choose the message you want to check if its read"); List <PersonalMessage> MessagesToChoose = GetMessages(); List <string> Messages = MessagesToChoose.Select(Message => Message.PersonalMessageText).ToList(); PersonalMessage MessageToCheck = MessagesToChoose[SelectMenu.Vertical(Messages).IndexOfChoice]; if (MessageToCheck.isRead == true) { Console.WriteLine("Message was read"); return(true); } else { Console.WriteLine("Message not read yet"); } Console.ReadKey(); return(false); }
public User SignOrLog(IDataHandler DataProvider) { while (true) { string ChoiceIfUserSignUpOrLogin = SelectMenu.Horizontal(new List <string> { SIGN_UP, LOGGIN }).NameOfChoice; if (ChoiceIfUserSignUpOrLogin == SIGN_UP) { User ActiveUser = SignUpNewUser(); Console.WriteLine("Welcome user " + ActiveUser.Username + " and password " + ActiveUser.Password); return(ActiveUser); } else if (ChoiceIfUserSignUpOrLogin == LOGGIN) { do { User ActiveUser = LoginUser(); if (ActiveUser == null) { Console.WriteLine("Invalid Username or Password, Please try again"); } else { Console.WriteLine("You are in!!"); return(ActiveUser); } }while (true); } else { Console.WriteLine("Wrong Choice, try again"); } } }
public bool UpdateUserAccess() { string UpdateSelection = SelectMenu.Horizontal(new List <string> { UPGRADE, DOWNGRADE, BACK }).NameOfChoice; switch (UpdateSelection) { case UPGRADE: User SelectedUser = MainActions.SelectUser(); switch (SelectedUser.TypeOfUser) { case UserType.Guest: Console.WriteLine("Upgrade to User or Admin;"); string AdminChoice = SelectMenu.Horizontal(new List <string> { USER, ADMIN }).NameOfChoice; switch (AdminChoice) { case USER: default: SelectedUser.TypeOfUser = UserType.User; break; case ADMIN: SelectedUser.TypeOfUser = UserType.Administrator; break; } break; case UserType.User: SelectedUser.TypeOfUser = UserType.Administrator; break; case UserType.Administrator: default: break; } DataProvider.UpdateUserAccess(SelectedUser); break; case DOWNGRADE: Console.WriteLine("Choose the user you want to Downgrade:"); User UserSelection = MainActions.SelectUser(); switch (UserSelection.TypeOfUser) { case UserType.Administrator: Console.WriteLine("Downgrade to User or Guest;"); string AdminChoice = SelectMenu.Horizontal(new List <string> { USER, GUEST }).NameOfChoice; switch (AdminChoice) { case USER: default: UserSelection.TypeOfUser = UserType.User; break; case GUEST: UserSelection.TypeOfUser = UserType.Guest; break; } break; case UserType.User: UserSelection.TypeOfUser = UserType.Guest; break; case UserType.Guest: default: break; } DataProvider.UpdateUserAccess(UserSelection); break; case BACK: return(false); } return(true); }