Exemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="commentRepository"></param>
        /// <param name="subComment"></param>

        public static void SubComment(ICommentRepository commentRepository, SubCommentParam subComment)
        {
            Comment comment = new Comment();

            comment.ArticleId   = subComment.ArticleId;
            comment.UserId      = subComment.UserId;
            comment.UserName    = subComment.UserName;
            comment.Content     = subComment.Content;
            comment.CommentDate = DateTime.Now;
            comment.AddTime     = DateTime.Now;
            commentRepository.Add(comment);
        }
Exemplo n.º 2
0
        public JsonResult SubComment([FromBody] SubCommentParam msg)
        {
            ReplyModel reply = new ReplyModel();

            try
            {
                Comment.SubComment(_commentRepository, msg);
                bool result = ServiceProvider.GetService <IUnitOfWork>().Commit();
                if (result)
                {
                    reply.Status = "002";
                    reply.Msg    = "评论成功";
                }
                else
                {
                    reply.Msg = "评论失败";
                }
            }
            catch (Exception ex)
            {
                reply.Msg = $"提交评论出现异常,请重试{ex.Message}";
            }
            return(Json(reply));
        }