// 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 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(""); } }