Exemplo n.º 1
0
        public ActionResult SaveMessageReply(SaveMessageReplyViewModel viewModel)
        {
            try
            {
                using (var transaction = UnitOfWork.Begin())
                {
                    _processor.Process <CreateArticleMessageReplyCommand>(new CreateArticleMessageReplyCommand(
                                                                              viewModel.ReplyMessageId,
                                                                              CurrentUser.UserId,
                                                                              viewModel.ReplyComment));
                    transaction.Commit();
                }
            }
            catch (Exception ex)
            {
                // 记录日志
                LogServer.Error("保存已登录用户评论失败", ex.Message, HttpContext.Request.Path);

                if ((ex is PowerException) || (ex is BusinessException))
                {
                    return(new JsonResultObjec <string>(false, ex.Message));
                }
                else
                {
                    return(new JsonResultObjec <string>(false, "评论失败,请联系管理员!"));
                }
            }
            return(new JsonResultObjec <string>(true, "评论成功"));
        }
Exemplo n.º 2
0
        public ActionResult CommentAnonymousUserReply(int replyId, int articleId)
        {
            var viewModel = new SaveMessageReplyViewModel()
            {
                ReplyMessageId = replyId
            };

            viewModel.ArticleId = articleId;
            viewModel.FormGuId  = Guid.NewGuid().ToString();
            return(View("_CommentAnonymousUserReply", viewModel));
        }
Exemplo n.º 3
0
        public ActionResult SaveAnonymousUserMessageReply(SaveMessageReplyViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    using (var transaction = UnitOfWork.Begin())
                    {
                        _processor.Process <CreateArticleMessageReplyCommand>(new CreateArticleMessageReplyCommand(
                                                                                  viewModel.ReplyMessageId,
                                                                                  viewModel.ReplyNickName,
                                                                                  viewModel.ReplyComment)
                        {
                            Email      = viewModel.ReplyEmail,
                            WebSiteUrl =
                                viewModel.ReplyWebSiteUrl
                        });

                        transaction.Commit();
                    }
                    return(new JsonResultObjec <string>(true, "评论成功"));
                }
                catch (Exception ex)
                {
                    // 记录日志
                    LogServer.Error("保存已登录用户评论失败", ex.Message, HttpContext.Request.Path);

                    if ((ex is PowerException) || (ex is BusinessException))
                    {
                        return(new JsonResultObjec <string>(false, ex.Message));
                    }
                    else
                    {
                        return(new JsonResultObjec <string>(false, "评论失败,请联系管理员!"));
                    }
                }
            }

            var errorStr = new StringBuilder();

            foreach (var item in ModelState)
            {
                foreach (var value in item.Value.Errors)
                {
                    errorStr.AppendLine(value.ErrorMessage);
                }
            }

            return(new JsonResultObjec <string>(false, string.Format("{0}", errorStr)));
        }