public static async Task <PostsPagedListViewModel> BuildDefaultModel(IPostAsyncRepository postRepository, int pageNum)
 {
     return(new PostsPagedListViewModel()
     {
         Posts = (await postRepository.GetAll()
                  .ToPagedListAsync(pageNum, PostsCountOnPage))
                 .Select(p => new PostPreviewViewModel(p))
     });
 }
示例#2
0
        public SidebarViewModel(IPostAsyncRepository postRepository, IAsyncRepository <Tag> tagRepository)
        {
            Task.Run(async() => {
                LatestPosts = postRepository.GetAll()
                              .OrderByDescending(p => p.Created)
                              .Take(15)
                              .Select(p => new PostPreviewViewModel(p))
                              .ToList();

                Tags = (await tagRepository.GetAll())
                       .Select(t => new TagViewModel(t))
                       .ToList();
            }).Wait();
        }