コード例 #1
0
        public IActionResult Index(NormalCommentModel model)
        {
            bool check = _postTokenManagerService.CheckAndDelPostToken(model.PostToken);

            if (check)
            {
                if (string.IsNullOrEmpty(model.CommentText) || string.IsNullOrEmpty(model.Email) || string.IsNullOrEmpty(model.Nikename))
                {
                    NormalCommentModel modelR = new NormalCommentModel()
                    {
                        PostToken = model.PostToken,
                        ServerMsg = "数据不完整"
                    };
                    return(View(modelR));
                }
                string        content       = _normalCommentService.ReplacementFilter(model.CommentText);
                NormalComment normalComment = new NormalComment()
                {
                    BlogId      = model.BlogId,
                    CreatedOn   = DateTime.Now,
                    CommentText = content,
                    Email       = model.Email,
                    Nikename    = model.Nikename,
                    IsDeleted   = false,
                    HomepageUrl = string.IsNullOrEmpty(model.HomepageUrl) ? "" : model.HomepageUrl,
                    PreIds      = ""
                };
                normalComment = _normalCommentService.CreateNormalComment(normalComment);
            }
            model = new NormalCommentModel()
            {
                ServerMsg = check?"提交成功":"Token丢失,提交失败,请尝试点击顶部留言连接"
            };
            return(View(model));
        }
コード例 #2
0
        public IViewComponentResult Invoke(int blogId = 0)
        {
            var cns = _normalCommentService.GetNormalComments(blogId, 10);

            if (cns == null)
            {
                return(View("NoData"));
            }
            List <NormalCommentModel> model = new List <NormalCommentModel>();

            foreach (var cn in cns)
            {
                NormalCommentModel m = new NormalCommentModel()
                {
                    Id           = cn.Id,
                    BlogId       = cn.BlogId,
                    CommentText  = cn.CommentText,
                    CreatedOnStr = cn.CreatedOn.ToLocalTime().ToLongDateString(),
                    Email        = cn.Email,
                    HomepageUrl  = cn.HomepageUrl,
                    IsDeleted    = cn.IsDeleted,
                    Nikename     = cn.Nikename,
                    PreIds       = cn.PreIds
                };
                model.Add(m);
            }
            return(View(model));
        }
コード例 #3
0
        public IActionResult Index()
        {
            NormalCommentModel model = new NormalCommentModel()
            {
                PostToken = _postTokenManagerService.GetNewPostToken(DateTime.Now.ToShortTimeString()),
                ServerMsg = "谢谢访问"
            };

            return(View(model));
        }
コード例 #4
0
        public IViewComponentResult Invoke()
        {
            NormalCommentModel model = new NormalCommentModel();

            return(View(model));
        }