public JsonResult Agree(ExpertQuestionReplyAgreeInput input) { var parameters = GetPostParameters(); var responseResult = PostStandardWithSameControllerAction <object>(this, parameters); return(new JsonResultEx(responseResult)); }
public JsonResult Agree(ExpertQuestionReplyAgreeInput input) { using (var result = new ResponseResult <object>()) { //判断该条回复是否存在 var replyModel = _expertQuestionReplyService.GetByKey(input.ReplyId); if (replyModel == null) { throw new CustomException("回复记录不存在!"); } //判断该条的问题是否存在 var question = _expertQuestionService.GetByKey(replyModel.QuestionId); if (question == null) { throw new CustomException("问题不存在!"); } //判断该问题的发起者是否是当前用户 if (question.UserId != input.UserId) { throw new CustomException("您没有操作该问题的权限!"); } ////判断该问题是否已经公开 //if (question.IsOpen) // throw new CustomException("该问题已公开,不能执行该操作!"); //判断该条回复是否已经采纳过 if (replyModel.IsAgree) { throw new CustomException("该回复已被提问者采纳,不得重复操作!"); } var hasAgreeReply = _expertQuestionReplyService.Count(m => m.QuestionId == replyModel.QuestionId && m.IsAgree) > 0; if (hasAgreeReply) { throw new CustomException("该问题已有被采纳的回复,不得重复操作!"); } replyModel.IsAgree = true; replyModel.LastModifiedTime = DateTime.Now; _expertQuestionReplyService.Update(replyModel); //将问题进行公开 question.IsOpen = true; _expertQuestionService.Update(question); result.Message = "处理同意操作成功!"; return(new JsonResultEx(result)); } }