Exemplo n.º 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,
     });
 }
Exemplo n.º 2
0
        public ActionResult Rate(string blogid, string rating)
        {
            int    id     = int.Parse(blogid);
            int    value  = int.Parse(rating);
            string status = _ratingUtil.TryRateBlog(id, value);

            if (status == "login")
            {
                return(Json(new { errmsg = "请登录后再评分!" }));
            }
            else if (status == "rated")
            {
                return(Json(new { errmsg = "您已经评过分了!" }));
            }
            else if (status == "rated_today")
            {
                return(Json(new { errmsg = "今天已经评过分了!" }));
            }
            else if (status == "error")
            {
                return(Json(new { errmsg = "无效的评分,请刷新重试" }));
            }
            var total = _ratingUtil.GetRating(id, false);

            if (HttpContext.Items["QuestMsg"] is string QuestMsg)
            {
                return(Json(new { rating = total, msg = QuestMsg }));
            }
            return(Json(new { rating = total }));
        }