private async Task QueryFollowings() { if (followingPage == 1) { if (FollowingUsers == null) { FollowingUsers = new ObservableCollection <FollowUser>(); } else { FollowingUsers.Clear(); } } UserContentProvider user = new UserContentProvider(); List <FollowUserInfo> result = await user.QueryFollowingUsers(followingPage, currentUserId, GlobalValue.CurrentUserContext.UserId, GlobalValue.CurrentUserContext.MobileToken); result.ForEach(x => FollowingUsers.Add(ConvertToFollowUser(x))); followingPage++; if (FollowingUsers.Count <= 10 && followingPage == 2) { await QueryFollowings(); } }
public ActionResult Followers(string id) { var currentUser = GetUser(); User user = String.IsNullOrEmpty(id) || currentUser.Id == id ? currentUser : _db.Users.Find(id); var targetUser = !(id == null || currentUser.Id == id); if (user == null) { return(HttpNotFound()); } List <FollowingUsers> followList = new List <FollowingUsers>(); List <UserFollow> followerUsers = _db.UserFollow.Where(e => e.UserBeingFollowedUserId == user.Id).ToList(); foreach (var item in followerUsers) { if (item.UserId == currentUser.Id) {//Ben onu takip ediyorum o beni takip ediyor mu ? FollowingUsers temp = new FollowingUsers(item.UserId, item.User.UserFirstName + " " + item.User.UserSurname, IsFollowingReverse(user), item.User.UserProfilePhoto); followList.Add(temp); } else {//şu an ki kullanıcı kendisini takip eden kullanıcıyı takip ediyor mu? FollowingUsers temp = new FollowingUsers(item.UserId, item.User.UserFirstName + " " + item.User.UserSurname, IsFollowing(item.User), item.User.UserProfilePhoto); followList.Add(temp); } } if (targetUser) { ViewBag.Following = IsFollowing(user); } ViewBag.email = currentUser.Email; ViewBag.userid = currentUser.Id; ViewBag.Model = followList; return(View(user)); }
private async void ExecuteFollowUserCommand(string userid) { FollowUser follower = FollowerUsers.FirstOrDefault(x => x.Id == userid); FollowUser following = FollowingUsers.FirstOrDefault(x => x.Id == userid); if (follower?.IsFollowing == true || following?.IsFollowing == true) { UserContentProvider user = new UserContentProvider(); FollowResult result = await user.UnFollowUser(userid, GlobalValue.CurrentUserContext.UserId, GlobalValue.CurrentUserContext.MobileToken); if (result.Error == null || result.Error.Count == 0) { if (follower != null) { follower.IsFollowing = false; } if (following != null) { following.IsFollowing = false; } } } else { UserContentProvider user = new UserContentProvider(); FollowResult result = await user.FollowUser(userid, GlobalValue.CurrentUserContext.UserId, GlobalValue.CurrentUserContext.MobileToken); if (result.Error == null || result.Error.Count == 0) { if (follower != null) { follower.IsFollowing = true; } if (following != null) { following.IsFollowing = true; } } } }