Exemple #1
0
 private BlogDetails GetBlogDetails(BlogDetailDisplay bd, User author, Comment[] comments, int?userrating)
 {
     return(new BlogDetails
     {
         Id = bd.blog.BlogID,
         Author = author,
         AuthorDesc = bd.AuthorDesc,
         Brief = blogUtil_.GetFirstLine(bd.blog, true).ToString(),
         CategoryId = bd.blog.CategoryID,
         ParentCategoryId = categoryUtil_.GetParentCategoryId(bd.blog.CategoryID),
         Content = BlogHelper.ReplaceContentImage(bd.blog),
         CreateDate = bd.blog.BlogDate,
         ImageUrls = bd.blog.IsLocalImg ? bd.blog.ImagePath?.Split(';') : new[] { bd.blog.ImagePath },
         ThumbUrl = BlogHelper.firstImgPath(bd.blog, true),
         Links = BlogHelper.GetBlogLink(bd.blog.Links),
         IsApproved = bd.blog.isApproved,
         LockTags = bd.Option.LockTags,
         NoComment = bd.Option.NoComment,
         NoRate = bd.Option.NoRate,
         Rating = ratingUtil_.GetRating(bd.blog.BlogID),
         Tags = bd.tag.ToDictionary(t => t.TagID, t => t.TagName),
         Title = bd.blog.BlogTitle,
         VisitCount = bd.blog.BlogVisit,
         TopComments = comments,
         IsFavorite = bd.IsFavorite,
         UserRating = userrating,
     });
 }
Exemple #2
0
        public async System.Threading.Tasks.Task <JsonResult> Blog([FromHybrid] SearchModel model, int limit = 10, int skip = 0)
        {
            limit = System.Math.Min(System.Math.Max(limit, 1), 100);
            int page = skip <= 0 ? 1 : (skip / limit + 1);

            if (IsHarmony)
            {
                model.Harmony = true;
            }
            var blogs = await searchProvider_.SearchBlogAsync(model, page, limit);

            var items = new X.PagedList.StaticPagedList <BlogPreview>(blogs.Blogs.Select(b =>
                                                                                         new BlogPreview {
                Brief      = blogUtil_.GetFirstLine(b, true).ToString(),
                Id         = b.BlogID,
                ThumbUrl   = BlogHelper.firstImgPath(b, true),
                ImageUrl   = BlogHelper.firstImgPath(b),
                Title      = b.BlogTitle,
                CreateDate = b.BlogDate,
                Url        = Url.Action("Details", "Blog", new { id = b.BlogID }, Request.Scheme),
            }), blogs.Blogs.GetMetaData());

            return(Json(new Paged <BlogPreview>(items)));
        }