//public RecoverAnswer getRecoverAnswerByTime(DateTime reAnswerTime) //{ // return _recoverAnswerRepository.Get(o => o.reAnswerTime == reAnswerTime).SingleOrDefault(); //} #endregion #region 对帮助者的评论内容进行回复 public bool recoverAnswer(RecoverAnswer recoverAnswer) { try { _recoverAnswerRepository.Add(recoverAnswer); return(true); } catch { return(false); } }
public ActionResult recoverAnswer(RecoverAnswer recoverAnswer, string recoverWho) { if (System.Web.HttpContext.Current.Session["loginUser"] == null) { JsonResult["boo_success"] = "pleaseLogin"; return(Json(JsonResult)); } else { recoverAnswer.reAnswerTime = DateTime.Now; recoverAnswer.reAnswerUserId = loginUser.userId; if (recoverWho == null) { if (_recoverAnswerService.recoverAnswer(recoverAnswer) == true) { User user = _userService.getUserById(recoverAnswer.reAnswerUserId); JsonResult["reAnswerUserImg"] = user.userImg; JsonResult["reAnswerUserName"] = user.userName; JsonResult["answerUserName"] = ""; JsonResult["boo_success"] = true; return(Json(JsonResult)); } else { JsonResult["boo_success"] = false; return(Json(JsonResult)); } } else { User u = _userService.getUserById(Convert.ToInt64(recoverAnswer.questionUserId)); recoverAnswer.answerUserName = u.userName; recoverAnswer.reAnswerContent = recoverAnswer.reAnswerContent.Replace(recoverWho, ""); if (_recoverAnswerService.recoverAnswer(recoverAnswer) == true) { User user = _userService.getUserById(recoverAnswer.reAnswerUserId); JsonResult["reAnswerUserImg"] = user.userImg; JsonResult["reAnswerUserName"] = user.userName; JsonResult["answerUserName"] = recoverAnswer.answerUserName; JsonResult["boo_success"] = true; return(Json(JsonResult)); } else { JsonResult["boo_success"] = false; return(Json(JsonResult)); } } } }