public void ShowWallForFriend(User wallOwner, User viewer) { List <Post> postsOnWall = new List <Post>(); List <Post> postsThatViewerHasAccessTo = new List <Post>(); //add all wall owners posts to list of posts on wall postsOnWall.AddRange(_postService.GetPostByAuthor(wallOwner)); //check if viewing friend has access to each post foreach (var post in postsOnWall) { var viewingFriendHasAccess = false; //break if list is empty if (post.ShownCircles == null) { continue; } //make list of circles that post is shown in List <Circle> postCircles = new List <Circle>(); foreach (var circleId in post.ShownCircles) { var circleToAdd = _circleService.GetCircleById(circleId); postCircles.Add(circleToAdd); } //check if subject is member of circles foreach (var circle in postCircles) { if (circle.Members == null) { continue; } if (circle.Members.Contains(viewer.Id)) { viewingFriendHasAccess = true; } } if (post.IsPublic == true) { viewingFriendHasAccess = true; } if (viewingFriendHasAccess == true) { postsThatViewerHasAccessTo.Add(post); } } Console.WriteLine($"-------------{wallOwner.Name}'s Wall-------------"); for (var x = 0; x < postsThatViewerHasAccessTo.Count; x++) { Console.WriteLine("****"); Console.WriteLine($"Post #{x + 1}, content type: {postsThatViewerHasAccessTo[x].PostType}"); if (postsThatViewerHasAccessTo[x].PostType == PostType.Text) { Console.WriteLine($"'{postsThatViewerHasAccessTo[x].PostText}'"); } else if (postsThatViewerHasAccessTo[x].PostType == PostType.Feeling) { Console.WriteLine($"'{postsThatViewerHasAccessTo[x].PostFeeling}'"); } Console.WriteLine($"Author: {postsThatViewerHasAccessTo[x].Author.Name}"); Console.WriteLine($"Date of post: {postsThatViewerHasAccessTo[x].Created}"); if (postsThatViewerHasAccessTo[x].Comments == null) { continue; } Console.WriteLine($"Comments:"); foreach (var y in postsThatViewerHasAccessTo[x].Comments) { Console.WriteLine($"'{y.Content}'"); Console.WriteLine($"Author: {y.Author.Name} "); Console.WriteLine($"Date of comment: {y.DateAndTime} "); Console.WriteLine("*"); } } }