private static void GetSortedPosts(CommonBoard commonBoardUser) { List <Message> messages = commonBoardUser.GetOrderedMessages(); foreach (Message message in messages) { Console.WriteLine(message.MessageContent); Console.WriteLine(message.MessagePostTime); } }
static void Main(string[] args) { //DisplayMenu(); IPostsService postsService = new PostsService(); CommonBoard commonboard = new CommonBoard(postsService); //create post Post firstPost = AddPost("Orsi Sebestyen", "This is the content of the first post", new DateTime(2019, 01, 19)); //create user User orsi = AddUser("*****@*****.**", "Orsolya", "Sebestyen", new DateTime(1994, 01, 01)); //showing/listing posts List<Post> posts = GetPosts(); }
static void Main(string[] args) { commonBoard = new CommonBoard(new UserService(), new MessageService()); Console.Write("Create your first account:\n"); CreateAccount(); bool loggedInOrNot = false; do { DisplayMenuAccountOrLogIn(); Console.Write("Your option is: "); int option = 0; int.TryParse(Console.ReadLine(), out option); switch (option) { case 1: CreateAccount(); break; case 2: LogIn(); loggedInOrNot = true; break; default: Console.WriteLine("Invalid option. Try again!"); break; } } while(!loggedInOrNot); while (true) { DisplayMenu(); Console.Write("Your option is: "); int option = 0; int.TryParse(Console.ReadLine(), out option); Console.WriteLine(); switch (option) { case 1: CreateAccount(); break; case 2: LogIn(); break; case 3: AddPost(); break; case 4: GetSortedPosts(commonBoard); break; case 5: return; default: Console.WriteLine("Invalid option. Try again!"); break; } Console.WriteLine(); } }