public void SearchUsers() { Console.Clear(); Title("Search for Users"); string key = JHelper.InputString("Enter Search Key: "); IList <User> users = Logic.SearchUser(key); while (true) { Console.Clear(); Title($"Search Results for \"{key}\""); // Display list of users DisplayEnumeratedList(users, e => e.Name); Console.Write(bar()); int userNumber = JHelper.InputInt("Enter Number (-1 to go Back): ", validator: e => e == -1 || (e > 0 && e <= users.Count)); if (userNumber == -1) { break; } UserProfile(users[userNumber - 1]); } }
public void Register() { Console.Clear(); // Enter Username string username = JHelper.InputString("Enter Username: "******""; string confirmPassword = "******"; while (password != confirmPassword) { password = JHelper.InputPassword("Enter Password: "******"Confirm Password: "******"> Please Enter the Same Password"); } } Logic.Register(username, password); Console.WriteLine("User Registered. You may now log in to your account."); JHelper.ContinuePrompt(); }
public void WelcomeScreen() { while (true) { Console.Clear(); Title("Welcome to Community"); Console.WriteLine( "[1] Login " + "[2] Register " + "[X] Exit" ); Console.Write(bar()); string selection = JHelper.InputString("Enter Selection: ", toUpper: true, validator: e => e.In("1", "2", "X")); if (selection == "1") { Login(); } else if (selection == "2") { Register(); } else if (selection == "X") { break; } } JHelper.ExitPrompt(); }
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; } } }
private void PostToCommunity(Community community) { Title($"Post to {community.Name}"); Console.Clear(); // Input text string text = JHelper.InputString("Enter Text: ", validator: e => !string.IsNullOrWhiteSpace(e) && !e.Contains("|")); Logic.PostToCommunity(text, community); }
public void CreateCommunity() { Console.Clear(); Title("Create Community"); string name = JHelper.InputString("Enter Community Name: ", validator: ValidCommunityName).ToLower();; Logic.CreateCommunity(name); Console.WriteLine("Community Created"); JHelper.ContinuePrompt(); }
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 SeeCommunityPosts(Community community) { var display = new EnumerableDisplay <UserPost>(community.Posts, 7, PostDisplay); while (true) { display.items = community.Posts.ToList(); Console.Clear(); Title($"{community.Name} Posts"); display.Display(); bool following = Logic.IsFollowingCommunity(community); Console.WriteLine( bar() + $"{(display.HasPreviousPage ? "[Q] Previous Page " : "")}" + $"{(display.HasNextPage ? "[W] Next page" : "")}" + (display.HasNextPage || display.HasPreviousPage ? "\n" : "") + $"[1] {(following ? "Leave" : "Join")} " + $"[2] Post " + "[X] Back"); Console.Write(bar()); string selection = JHelper.InputString("Enter Selection: ", toUpper: true, validator: e => e.In("1", "2", "X")); if (selection == "1") { if (following) { Logic.UnfollowCommunity(community); } else { Logic.FollowCommunity(community); } } else if (selection == "2") { PostToCommunity(community); } else if (selection == "X") { break; } } }
public void Login() { while (true) { Console.Clear(); // Enter Username string username = JHelper.InputString("Enter Username: "******"Enter Password: "******"Please Enter A Valid Username and Password"); JHelper.ContinuePrompt(); } MainMenu(); }
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; } } }