/// <summary> /// Returns a <see cref="BlogPostList"/> based on query from data source. /// </summary> /// <param name="query"></param> /// <returns></returns> private async Task <BlogPostList> QueryPostsAsync(PostListQuery query) { var(posts, totalCount) = await _postRepo.GetListAsync(query); var blogPostList = new BlogPostList { PostCount = totalCount }; foreach (var post in posts) { var blogPost = await GetBlogPostAsync(post); blogPost = await PreRenderAsync(blogPost); blogPostList.Posts.Add(blogPost); } return(blogPostList); }
public BlogPostList GetBlogPosts(string tagName) { BlogPostList blogPostList = new BlogPostList(); if (tagName == null) { blogPostList.BlogPostDtos = BlogDBContext.BlogPosts .Select(x => MapFromDb(x)) .ToList(); } else { blogPostList.BlogPostDtos = BlogDBContext.BlogPostTags .Where(x => x.Tag.Name == tagName) .Select(x => MapFromDb(x.BlogPost)) .ToList(); } return(blogPostList); }
public BlogPostListViewModel(BlogPostList blogPostList, BlogSettings blogSettings, HttpRequest request, Tag tag) : this(blogPostList, blogSettings, request) { TagTitle = tag.Title; Description = tag.Description; }
public BlogPostListViewModel(BlogPostList blogPostList, BlogSettings blogSettings, HttpRequest request, Category cat) : this(blogPostList, blogSettings, request) { CategoryTitle = cat.Title; Description = cat.Description; }