public JsonResult Reply(ExpertQuestionReplyInput input)
        {
            var parameters     = GetPostParameters();
            var responseResult = PostStandardWithSameControllerAction <object>(this, parameters);

            return(new JsonResultEx(responseResult));
        }
        public JsonResult Reply(ExpertQuestionReplyInput input)
        {
            using (var result = new ResponseResult <object>())
            {
                var model    = Mapper.Map <T_QUESTION_REPLY>(input);
                var question = _expertQuestionService.GetByKey(input.QuestionId);

                //判断该条的问题是否存在
                if (question == null)
                {
                    throw new CustomException("问题不存在!");
                }

                //判断该问题是否已经公开
                if (question.IsOpen)
                {
                    throw new CustomException("该问题已公开,不能执行该操作!");
                }

                result.IsSuccess = _expertQuestionReplyService.Insert(model) > 0;
                if (!result.IsSuccess)
                {
                    return(new JsonResultEx(result));
                }

                result.Message = "回答成功!";
                //更新该问题的回复数
                question.ReplyCount += 1;
                _expertQuestionService.Update(question);

                //添加先锋币
                var roleType = (RoleType)question.RoleId;
                if (roleType == RoleType.Farmer)
                {
                    var userInfo = _userService.GetByKey(input.ReplyUserId);
                    if (userInfo != null)
                    {
                        userInfo.DPoint = (userInfo.DPoint ?? 0) + 5;
                        _userService.Update(userInfo);
                    }
                }

                //给问题的提问者推送通知
                _notificationService.Insert(new T_NOTIFICATION
                {
                    MsgContent           = "有人回答了你的问题,快去看看吧!",
                    IsPublic             = false,
                    TargetUserId         = question.UserId,
                    NotificationType     = 2,
                    NotificationSource   = "",
                    NotificationSourceId = question.Id,
                    IsOpen = question.IsOpen,
                });

                return(new JsonResultEx(result));
            }
        }