/// <summary> /// This allows the user to remove a post that has /// been made /// </summary> /// <param name="id"></param> public void RemovePost(int id) { Post post = FindPost(id); if (post == null) { Console.WriteLine($" \nPost with ID = {id} does not exists!!\n"); } else { Console.WriteLine($" \nThe following Post {id} has been removed!\n"); if (post is MessagePost mp) { mp.Display(); } else if (post is PhotoPost pp) { pp.Display(); } posts.Remove(post); post.Display(); } }
///<summary> /// This is what will show you the news feed. ///</summary> public void Display() { // display all text posts foreach (Post Post in Posts) { Post.Display(); Console.WriteLine(); // empty line between posts } }
/// <summary> /// where the user adds a Comment onto a post /// </summary> private void Comment() { Console.WriteLine("Comment on a Post"); Post post = FindPost(); post.Display(); Console.WriteLine("Please Enter your Comment"); string comment = Console.ReadLine(); post.AddComment(comment); }
/// <summary> /// a method to add a comment to a post /// </summary> private void AddComment() { ConsoleHelper.OutputTitle("Adding a Comment"); Post post = FindPost(); post.Display(); Console.WriteLine("Enter Comment > "); string comment = Console.ReadLine(); post.AddComment(comment); }
/// <summary> /// Adds a comment /// </summary> private void AddComment() { Console.WriteLine("Add a comment to a post"); Post post = FindPost(); post.Display(); Console.WriteLine("Enter your comment: "); string comment = Console.ReadLine(); post.AddComment(comment); }
/// <summary> /// Displays posts for particular author /// </summary> /// <param name="username"></param> public void DisplayAuthor(string username) { Post post = FindAuthor(username); if (post == null) { Console.WriteLine("No posts from", username, " exist."); } else { Console.WriteLine("Displaying all posts from ", username); post.Display(); } }
/// <summary> /// Displays all posts for particular time. /// </summary> /// <param name="time"></param> public void DisplayByTime(int time) { Post post = FindTime(time); if (post == null) { Console.WriteLine("No posts in this period", time, "seconds; exist."); } else { Console.WriteLine("Displaying all posts for this period ", time, "seconds"); post.Display(); } }
/// <summary> /// Likes post with particular id /// </summary> /// <param name="id"></param> public void LikePost(int id) { Post post = FindPost(id); if (post == null) { Console.WriteLine("Post with id ", id, " does not exist."); } else { Console.WriteLine("Post has been liked."); post.Like(); post.Display(); } }
/// <summary> /// Display search results for posts by author or date. /// </summary> private void DisplayResults(int i, Post post) { ConsoleHelper.Cyan(); Console.WriteLine($"\n -- Showing {i}/{SearchPosts} posts --"); ConsoleHelper.White(); post.Display(); if (i == SearchPosts) { BlueAlert = " -- End of posts --\n"; } }
/// <summary> /// Unlike a post based on the given id post /// </summary> public void UnlikePost(int id) { Post post = FindPost(id); if (post == null) { Console.WriteLine($"\nPost with ID: {id} does not exist!\n"); } else { Console.WriteLine($"\nYou have unliked the the following post {id}!\n"); post.Unlike(); post.Display(); } }
/// <summary> /// Add comments based on the post id /// then add text on the post /// </summary> public void AddPostComment(int id, string text) { Post post = FindPost(id); if (post == null) { Console.WriteLine($"\nPost with ID: {id} does not exist!\n"); } else { Console.WriteLine($"\nThe following comment have been added to post {id}!\n"); post.AddComment(text); post.Display(); } }
/// <summary> /// Removes a post from the news feed based on /// the post's ID. /// </summary> public void RemovePost(int id) { Post post = FindPostById(id); if (post == null) { Console.WriteLine($"\n\tPost with ID {id} doesn't exist."); } else { Console.WriteLine($"\n\tPost with ID {id} has " + $"been removed from the news feed.\n"); posts.Remove(post); post.Display(); } }
/// <summary> /// Allows you to fins post by username. /// </summary> public void FindUser(string user) { int counter = 0; foreach (Post Post in Posts) { if (Post.Username == user) { Post.Display(); Console.WriteLine(); counter++; } } if (counter == 0) { Console.WriteLine("\nNo such user exists in the current context "); } }
public void FindUser(string user) { int counter = 0; foreach (post Post in posts) { if (Post.Username == user) { Post.Display(); Console.WriteLine(); counter++; } if (counter == 0) { Console.WriteLine("\n This User does not Exist in the current context"); } } }
/// <summary> /// Adds a comment to a post with a given ID and comment /// by the user. /// </summary> public void AddComment(int id, string comment) { Post post = FindPostById(id); if (post == null) { Console.WriteLine($"\n\tPost with ID {id} doesn't exist."); } else if (comment == "") { Console.WriteLine($"\n\tNo comment has been entered."); } else { Console.WriteLine("\n\tComment has been added to post with " + $"ID {id}\n"); post.AddComment(comment); post.Display(); } }