public ViewResult Friends(string userId = null) { if (_user.IsBlocked) { return(View("NoAccess", "Home")); } User user = userId == null ? _user:_repository.GetUserById(userId); var friends = _repository.GetUsersFriends(user); var followers = user.Followers; var followings = user.Following; foreach (var friend in friends) { _repository.GetUsersMainPhoto(friend); } foreach (var follower in followers) { _repository.GetUsersMainPhoto(follower); } foreach (var following in followings) { _repository.GetUsersMainPhoto(following); } FriendsRequestsViewModel friendsVM = new FriendsRequestsViewModel { Friends = user.Friends, Followers = user.Followers, Following = user.Following }; if (user == _user) { friendsVM.Requests = user.IncomingFrienshipRequests.Where(r => r.Status == FriendshipStatus.Waiting) .Select(r => r.RequestFrom).ToList(); foreach (var r in friendsVM.Requests) { _repository.GetUsersMainPhoto(r); } } return(View(friendsVM)); }
public FriendsRequestsView() { InitializeComponent(); _vm = new FriendsRequestsViewModel(); DataContext = _vm; }