public IActionResult Index(string circleId) { CircleWallViewModel viewModel = new CircleWallViewModel() { Circle = _circleService.GetById(circleId), Posts = _postService.GetByCircleId(circleId, Program.CurrentUser), }; return(View("Wall", viewModel)); }
public List <Post> GetPosts(string queryUserId) { List <Post> feedPosts = new List <Post> (); User queryUser = _userService.GetById(queryUserId); foreach (string postId in queryUser.PostIds) { feedPosts.Add(_postService.GetById(postId)); } foreach (string followId in queryUser.FollowUserIds) { if (!queryUser.BlackListUserIds.Contains(followId)) { User followUser = _userService.GetById(followId); foreach (string postId in followUser.PostIds) { Post followUserPost = _postService.GetById(postId); if (followUserPost.CircleId == null) { feedPosts.Add(followUserPost); } } } } foreach (string circleId in queryUser.SubscribedCircleIds) { Circle followCircle = _circleService.GetById(circleId); foreach (string postId in followCircle.PostIds) { Post followCirclePost = _postService.GetById(postId); if (!queryUser.BlackListUserIds.Contains(followCirclePost.UserId)) { feedPosts.Add(followCirclePost); } } } feedPosts.Sort(); feedPosts.Reverse(); return(feedPosts.GroupBy(p => p.Id).Select(p => p.First()).Take(6).ToList()); }