/// <summary> /// 'this' follows user followee /// </summary> /// <param name="followee"></param> public void AddFollowing(User followee) { Following.Add(new UserFollow() { Followee = followee, Follower = this }); //followee }
/// <summary> /// Init following from settings /// </summary> private void initFollowing() { this.Following = new ObservableCollection <FollowItem>(); foreach (FollowItem item in App.AppSettingsManager.Followings) { Following.Add(item); } this.Following.CollectionChanged += Following_CollectionChanged; }
public async Task FollowUser(User user, HttpClient client) { if (!Logged) { return; } client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", Token); var response = await client.PostAsync($"api/users/{user.Id}/follow", null); if (response.StatusCode == HttpStatusCode.OK) { Following.Add(user); FollowingCount++; } }
public bool Follow(ProfileAggregate otherAggregate) { if (otherAggregate == default) { throw new ArgumentException("The user cannot be null"); } if (otherAggregate.Id == Guid.Empty) { throw new ArgumentException("userid cannot be empty"); } Follower follow = Following.Find(follow => follow.FollowerId == Id && follow.FollowingId == otherAggregate.Id); if (follow != default) { return(false); } follow = new(Id, otherAggregate.Id); otherAggregate.AddFollower(follow); Following.Add(follow); return(true); }
private async Task Init() { var followers = await _userFollowersService.Get <List <Model.UserFollowers> >(new UserFollowersSearchRequest() { UserId = APIService.loggedProfile.UserId }); var following = await _userFollowersService.Get <List <Model.UserFollowers> >(new UserFollowersSearchRequest() { FollowedByUserId = APIService.loggedProfile.UserId }); foreach (var item in followers) { Followers.Add(await _userService.GetById <Model.UserProfile>(item.FollowedByUserId)); } foreach (var item in following) { Following.Add(await _userService.GetById <Model.UserProfile>(item.UserId)); } FollowersNumber = "Followers: " + followers.Count().ToString(); FollowingNumber = "Following: " + following.Count().ToString(); }
public async Task UpdateFollowing(bool useCursor = false) { if (UpdatingFollowing) { return; } if (Tokens == null) { return; } if (useCursor && _followingCursor == 0) { return; } UpdatingFollowing = true; if (!useCursor || _followingCursor == 0) { Following.Clear(); } try { var param = new Dictionary <string, object> { { "user_id", Tokens.UserId }, { "count", 20 } }; if (useCursor && _followingCursor != 0) { param.Add("cursor", _followingCursor); } var following = await Tokens.Friends.ListAsync(param); if (!useCursor || _followingCursor == 0) { Following.Clear(); } foreach (var user in following) { Following.Add(user); } _followingCursor = following.NextCursor; } catch { if (!useCursor || _followingCursor == 0) { Following.Clear(); } UpdatingFollowing = false; return; } UpdatingFollowing = false; }
internal void Follow(ApplicationUser user) { Following.Add(user); user.Followers.Add(this); }