public void MainMenu() { IEnumerable <UserPost> posts = Logic.GetMainFeed(); EnumerableDisplay <UserPost> display = new EnumerableDisplay <UserPost>(posts, 7, PostDisplay); while (true) { Console.Clear(); display.items = Logic.GetMainFeed().ToList(); Title("Home"); // Display List of Posts display.Display(); // Display and Input Selection Console.WriteLine( bar() + $"{(display.HasPreviousPage ? "[Q] Previous Page " : "")}" + $"{(display.HasNextPage ? "[W] Next page" : "")}" + (display.HasNextPage || display.HasPreviousPage ? "\n" : "") + "[1] Create Post " + "[2] Users " + "[3] Communities " + "[4] Profile " + "[X] Logout"); Console.Write(bar()); string selection = JHelper.InputString("Enter Selection: ", toUpper: true, validator: e => e.In("Q", "W", "1", "2", "3", "4", "X")); // Perform selection if (display.HasPreviousPage && selection == "Q") { display.PreviousPage(); } else if (display.HasNextPage && selection == "W") { display.NextPage(); } else if (selection == "1") { CreatePost(); } else if (selection == "2") { UsersMenu(); } else if (selection == "3") { CommunitiesMenu(); } else if (selection == "4") { SeeOwnProfile(); } else if (selection == "X") { break; } } }
public void SeeOwnProfile() { User user = Logic.GetLoggedinUser(); IEnumerable <UserPost> posts = user.Posts; EnumerableDisplay <UserPost> display = new EnumerableDisplay <UserPost>(posts, 5, PostDisplay); while (true) { Console.Clear(); display.items = user.Posts.ToList(); // Display Profile Description Title($"Profile of {user.Name}"); // Display Posts Console.WriteLine("Posts: "); display.Display(); // Get Input bool followed = Logic.IsFollowed(user); Console.WriteLine( bar() + $"{(display.HasPreviousPage ? "[Q] Previous Page " : "")}" + $"{(display.HasNextPage ? "[W] Next Page" : "")}" + (display.HasNextPage || display.HasPreviousPage ? "\n" : "") + "[1] See Joined Communities " + "[2] See Followed Users " + "[X] Back"); Console.Write(bar()); string selection = JHelper.InputString("Enter Selection: ", toUpper: true, validator: e => e.In("Q", "W", "1", "2", "X")); if (display.HasPreviousPage && selection == "Q") { display.PreviousPage(); } else if (display.HasNextPage && selection == "W") { display.NextPage(); } else if (selection == "1") { SeeFollowedCommunities(user); } else if (selection == "2") { SeeFollowedUsers(user); } else if (selection == "X") { break; } } }
// USERS MODULE public void UsersMenu() { IEnumerable <UserPost> posts = Logic.GetUserFeed(); EnumerableDisplay <UserPost> display = new EnumerableDisplay <UserPost>(posts, 7, PostDisplay); while (true) { Console.Clear(); display.items = Logic.GetUserFeed().ToList(); Title("Users Feed"); display.Display(); Console.WriteLine( bar() + $"{(display.HasPreviousPage ? "[Q] Previous Page " : "")}" + $"{(display.HasNextPage ? "[W] Next Page" : "")}" + (display.HasNextPage || display.HasPreviousPage ? "\n" : "") + "[1] See Recommended Users " + "[2] Search Users " + "[X] Back"); Console.Write(bar()); string selection = JHelper.InputString("Enter Selection: ", toUpper: true, validator: e => e.In("Q", "W", "1", "2", "X")); if (display.HasPreviousPage && selection == "Q") { display.PreviousPage(); } else if (display.HasNextPage && selection == "W") { display.NextPage(); } else if (selection == "1") { SeeRecommendedUsers(); } else if (selection == "2") { SearchUsers(); } else if (selection == "X") { break; } else { Console.WriteLine("Please Enter a Valid Selection."); } } }
public void UserProfile(User user) { IEnumerable <UserPost> posts = user.Posts; EnumerableDisplay <UserPost> display = new EnumerableDisplay <UserPost>(posts, 5, PostDisplay); while (true) { Console.Clear(); IEnumerable <Community> communities = Logic.CommonCommunities(user).Take(5); IEnumerable <User> followedUsers = Logic.CommonFollowedUsers(user).Take(5); display.items = user.Posts.ToList(); // Display Profile Description Title($"Profile of {user.Name}"); // Display Common Communities Console.WriteLine("Communities in Common: " + string.Join(", ", communities.Select(e => e.Name))); Console.WriteLine("Followed Users in Common: " + string.Join(", ", followedUsers.Select(e => e.Name))); // Display Posts Console.WriteLine("\nPosts: "); display.Display(); // Get Input bool followed = Logic.IsFollowed(user); Console.WriteLine( bar() + $"{(display.HasPreviousPage ? "[Q] Previous Page " : "")}" + $"{(display.HasNextPage ? "[W] Next Page" : "")}" + (display.HasNextPage || display.HasPreviousPage ? "\n" : "") + $"[1] {(followed ? "Unfollow User" : "Follow User ")} " + "[2] See Joined Communities " + "[3] See Followed Users " + "[X] Back"); Console.Write(bar()); string selection = JHelper.InputString("Enter Selection: ", toUpper: true, validator: e => e.In("Q", "W", "1", "2", "3", "X")); if (display.HasPreviousPage && selection == "Q") { display.PreviousPage(); } else if (display.HasNextPage && selection == "W") { display.NextPage(); } else if (selection == "1") { if (followed) { Logic.UnfollowUser(user); } else { Logic.FollowUser(user); } } else if (selection == "2") { SeeFollowedCommunities(user); } else if (selection == "3") { SeeFollowedUsers(user); } else if (selection == "X") { break; } } }