Ejemplo n.º 1
0
 public MainMenu(IProvideData dataprovider, User LoggedInUser)
 {
     ActiveUser          = LoggedInUser;
     DataProvider        = dataprovider;
     SelectionMenu       = new SelectionMenu();
     SpecificMenuActions = new SpecificMenu(DataProvider, ActiveUser);
 }
Ejemplo n.º 2
0
        public void ShowRecievedMessages()
        {
            while (true)
            {
                // Get the messages
                List <PersonalMessage> PersonalMessages = GetRecievedMessages(IsUserSender: false);

                // User select one
                int indexOfSelectedMessage = SelectionMenu.Vertical(PresentPersonalMessages(PersonalMessages)).IndexOfChoice;

                // Mark it as read
                DataProvider.UpdateMessageAsRead(PersonalMessages[indexOfSelectedMessage].PersonalMessageId);

                // Choose action on READ message
                ManageMessage(indexOfSelectedMessage, PersonalMessages);
            }
        }
Ejemplo n.º 3
0
        private int GetRecieverId()
        {
            List <string> ListOfRecievers = DataProvider.ReadUsers().Select(u => u.Username).ToList();

            ListOfRecievers.Remove(ActiveUser.Username);
            if (ListOfRecievers.Count == 0)
            {
                return(-1);
            }
            else
            {
                string reciever = SelectionMenu.Vertical(ListOfRecievers, "Whom do you want to send your message to?").NameOfChoice;
                Console.CursorVisible = false;
                User userReciever = DataProvider.ReadUsers().SingleOrDefault(u => u.Username == reciever);
                return(userReciever.UserId);
            }
        }
Ejemplo n.º 4
0
        public void Forum()
        {
            while (true)
            {
                string SelectedAction = SelectionMenu.Horizontal(new List <string> {
                    SEND_MESSAGE, BACK
                }, ForumMessageActions.ShowPrevious()).NameOfChoice;
                switch (SelectedAction)
                {
                case SEND_MESSAGE:
                    ForumMessageActions.Send();
                    break;

                case BACK:
                    return;
                }
            }
        }
Ejemplo n.º 5
0
        private void ManageMessage(int indexOfSelectedMessage, List <PersonalMessage> PersonalMessages)
        {
            string messageAction = SelectionMenu.Horizontal(new List <string> {
                "Reply", "Delete", "Back"
            }, PersonalMessages[indexOfSelectedMessage].MessageText).NameOfChoice;

            switch (messageAction)
            {
            case "Reply":
                ReplyToMessage(indexOfSelectedMessage, PersonalMessages);
                return;

            case "Delete":
                DeleteMessage(IsSender: false);
                return;

            case "Back":
                return;
            }
        }
Ejemplo n.º 6
0
        public void DeleteMessage(bool IsSender)
        {
            List <PersonalMessage> messageList     = DataProvider.ReadPersonalMessages(ActiveUser, IsSender);
            List <string>          MessageTextList = new List <string>();

            foreach (PersonalMessage message in messageList)
            {
                if ((message.SenderID == ActiveUser.UserId && message.IsMessageShownToSender) || (message.RecieverID == ActiveUser.UserId && message.IsMessageShownToReciever))
                {
                    MessageTextList.Add(message.MessageText);
                }
            }
            if (MessageTextList.Count == 0)
            {
                Console.WriteLine("No message found!");
                Console.ReadKey();
                return;
            }
            else
            {
                bool IsUserSender;
                MessageTextList.Add("Back");
                int index = SelectionMenu.Vertical(MessageTextList, "Delete any message").IndexOfChoice;
                if (index == MessageTextList.Count - 1)
                {
                    return;
                }
                else
                {
                    if (messageList[index].SenderID == ActiveUser.UserId)
                    {
                        IsUserSender = true;
                    }
                    else
                    {
                        IsUserSender = false;
                    }
                    DataProvider.DeleteSelectedPersonalMessage(messageList[index], IsUserSender);
                }
            }
        }
Ejemplo n.º 7
0
        public void ManageUserMenu()
        {
            string actionselected;

            while (true)
            {
                List <string> Options = (ActiveUser.UsersPrivilege == Privilege.admin) ?
                                        new List <string> {
                    DISABLE_USER, UPGRADE_USER, CREATE_USER, SHOW_DETAILS, BACK
                }
                    : new List <string> {
                    SHOW_DETAILS, BACK
                };

                actionselected = SelectionMenu.Vertical(Options).NameOfChoice;
                switch (actionselected)
                {
                case DISABLE_USER:
                    ManageUser.Disable();
                    break;

                case UPGRADE_USER:
                    ManageUser.UpdateUser();
                    break;

                case CREATE_USER:
                    ManageUser.CreateUser();
                    break;

                case SHOW_DETAILS:
                    ManageUser.ShowDetails();
                    break;

                case BACK:
                    return;
                }
            }
        }
Ejemplo n.º 8
0
        public void MessagesMenu(User ActiveUser)
        {
            string messageselection;

            while (true)
            {
                string RecievedMessages = "Recieved" + PersonalMessageActions.CheckForUnreadMessages();
                messageselection = SelectionMenu.Vertical(new List <string> {
                    SEND_MESSAGE, SENT, RecievedMessages, DELETE_SENT, DELETE_RECIEVED, BACK
                }, Headers.MessageMenuHeader).NameOfChoice;

                if (messageselection == SEND_MESSAGE)
                {
                    PersonalMessageActions.SendPersonalMessage();
                }
                else if (messageselection == SENT)
                {
                    PersonalMessageActions.ShowSent(IsUserSender: true);
                }
                else if (messageselection == RecievedMessages)
                {
                    PersonalMessageActions.ShowRecievedMessages();
                }
                else if (messageselection == DELETE_SENT)
                {
                    PersonalMessageActions.DeleteMessage(IsSender: true);
                }
                else if (messageselection == DELETE_RECIEVED)
                {
                    PersonalMessageActions.DeleteMessage(IsSender: false);
                }
                else
                {
                    return;
                }
            }
        }
 public UserManager(IProvideData dataprovider, User activeuser)
 {
     DataProvider  = dataprovider;
     SelectionMenu = new SelectionMenu();
     ActiveUser    = activeuser;
 }
 public LoginOrSignup(IProvideData dataprovider)
 {
     SelectionMenu = new SelectionMenu();
     DataProvider  = dataprovider;
 }