コード例 #1
0
ファイル: BlogPostService.cs プロジェクト: BionStt/Fanray
        /// <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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
 public BlogPostListViewModel(BlogPostList blogPostList, BlogSettings blogSettings, HttpRequest request, Tag tag)
     : this(blogPostList, blogSettings, request)
 {
     TagTitle    = tag.Title;
     Description = tag.Description;
 }
コード例 #4
0
 public BlogPostListViewModel(BlogPostList blogPostList, BlogSettings blogSettings, HttpRequest request, Category cat)
     : this(blogPostList, blogSettings, request)
 {
     CategoryTitle = cat.Title;
     Description   = cat.Description;
 }