Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        public bool CreateMessage()
        {
            User Receiver = MainActions.SelectUser();

            Console.WriteLine("Add a title:");
            string title = Console.ReadLine();

            Console.WriteLine("Send the message");
            string text = Console.ReadLine();

            PersonalMessage NewPersonalMessage = new PersonalMessage()
            {
                SenderID            = ActiveUser.UserID,
                ReceiverID          = Receiver.UserID,
                TitleText           = title,
                PersonalMessageText = text
            };

            return(DataHandler.CreatePersonalMessageData(NewPersonalMessage));
        }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
        public bool DeletePersonalMessage(PersonalMessage DeletedMessage, User sender)
        {
            List <string> AllLines = File.ReadLines(@"C:\Users\user\Desktop\PersonalMessages.txt").ToList();
            int           index    = 0;

            foreach (string line in AllLines)
            {
                string[] ListElements = line.Split(' ');

                if (ListElements[2] == DeletedMessage.PersonalMessageText)
                {
                    index = AllLines.IndexOf(line);
                    AllLines.RemoveAt(index);
                    break;
                }
                else
                {
                    index++;
                }
            }
            File.WriteAllLines(@"C:\Users\user\Desktop\ForumMessages.txt", AllLines);
            return(true);
        }
Ejemplo n.º 6
0
        public bool UpdatePersonalMessage(PersonalMessage OldPersonalMessage, string NewPersonalMessageText)
        {
            List <string> AllLines = File.ReadLines(@"C:\Users\user\Desktop\PersonalMessages.txt").ToList();
            int           index    = 0;

            foreach (string line in AllLines)
            {
                string[] ListElements = line.Split(' ');

                if (ListElements[2] == OldPersonalMessage.PersonalMessageText)
                {
                    index           = AllLines.IndexOf(line);
                    AllLines[index] = NewPersonalMessageText;
                    break;
                }
                else
                {
                    index++;
                }
            }
            File.WriteAllLines(@"C:\Users\user\Desktop\ForumMessages.txt", AllLines);
            return(true);
        }
Ejemplo n.º 7
0
 public bool CreatePersonalMessageData(PersonalMessage personal)
 {
     File.AppendAllText(@"C:\Users\user\Desktop\PersonalMessages.txt", personal.PersonalMessageId + " " + personal.Sender.UserID + " " + personal.SendDate + " " + personal.PersonalMessageText + " " + personal.Receiver.UserID);
     return(true);
 }
Ejemplo n.º 8
0
 public void SavePersonalMessage(PersonalMessage PM)
 {
     File.AppendAllText(@"C:\Users\user\Desktop\PersonalMessages.txt",
                        $"{GetNewPersonalMessageID()} {PM.SenderID} {PM.SendDate} {PM.PersonalMessageText} {PM.ReceiverID}");
 }
Ejemplo n.º 9
0
 public bool MarkMessageAsRead(PersonalMessage ReadMessage)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 10
0
        public bool DeleteMessage()
        {
            PersonalMessage WantedMessage = GetWantedMessage(ActiveUser);

            return(DataHandler.DeletePersonalMessage(WantedMessage, ActiveUser));
        }