- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
private PostsPageViewModel GetUserPosts(Guid userId, int? pageIndex)
{
var posts = entitiesDB.Posts
.Where(post => post.UserId == userId)
.OrderByDescending(p => p.DateCreated)
.Select(post => new PostViewModel()
{
Contents = post.Contents,
DateCreated = post.DateCreated,
PostId = post.PostId,
AuthorId = userId,
AssociatedTags = post.Tags.Select(t => new TagViewModel() { TagId = t.TagId, Contents = t.Contents }).ToList()
})
.ToPagedList(pageIndex ?? 1, 10);
PostsPageViewModel viewModel = new PostsPageViewModel()
{
Posts = posts,
RouteValues = new { controller = "Posts", action = "UserPosts" }
};
return viewModel;
}