private void fillInProfile(User user) { userTitleLabel.Text = user.username; int followers = user.getFollowerCount(); if(followers > 0) { followerCountLabel.Text = "Followers: " + followers; } else { followerCountLabel.Text = "No Followers"; } listGrid.DataSource = MovieListManager.getMovieLists(user.username); reviewGrid.DataSource = ReviewManager.getReviewsByAuthor(user.username); listGrid.Columns[0].Visible = false; listGrid.Columns[2].Visible = false; reviewGrid.Columns[0].Visible = false; reviewGrid.Columns[1].Visible = false; if (ApplicationManager.loggedIn == null || ApplicationManager.loggedIn.username.Equals(user.username)) { followButton.Hide(); } else { if(ApplicationManager.loggedIn != null) { followButton.Show(); if (ApplicationManager.loggedIn.isFollowing(user.username)) { followButton.Text = "Unfollow"; } else { followButton.Text = "Follow"; } } } if (ApplicationManager.loggedIn != null && ApplicationManager.loggedIn.username.Equals(user.username)) { manageFollowingButton.Show(); editColorsButton.Show(); } else { manageFollowingButton.Hide(); editColorsButton.Hide(); } }
public static List<FormError> createUser(string uname, string pwd) { List<FormError> errors = new List<FormError>(); User user = new User() { username = uname, password = pwd, following = new List<string>(), userColors = getDefaultUserColors() }; if (user.valid(errors)) { List<User> users = DataAccess.readUsers(); users.Add(user); DataAccess.writeUsers(users); } return errors; }
public static void setUserColor(User user, int colID, int color) { user.userColors[colID] = color; saveUser(user); }
public static void setUserColor(User user, int colID, Color color) { user.userColors[colID] = color.ToArgb(); saveUser(user); }
public static bool saveUser(User user) { List<User> users = DataAccess.readUsers(); int i = 0; while(i < users.Count && !users.ElementAt(i).username.Equals(user.username)) { i++; } if(i < users.Count) { users.ElementAt(i).following = user.following; users.ElementAt(i).userColors = user.userColors; DataAccess.writeUsers(users); return true; } return false; }
public static void updateListOrder(User user, List<MovieList> lists) { List<MovieList> mls = DataAccess.readMovieLists(); int i; foreach (MovieList list in lists) { i = 0; while (i < mls.Count && mls[i].ID != list.ID) { i++; } if(i < mls.Count) { mls.RemoveAt(i); mls.Add(list); } } DataAccess.writeMovieLists(mls); }