public ActionResult AddComment() { UserObj user = AppData.SessionUser; if (user == null) { return(Json(new { success = false, msg = "IS_NOT_LOGIN" })); } Validation vld = new Validation(); ProductBLL productBLL = new ProductBLL(); int productId = vld.GetInt("productId"); if (!productBLL.IsBuy(user.UserID, productId)) { return(Json(new { success = false, msg = "IS_NOT_BUY" })); } if (productBLL.IsComment(user.UserID, productId)) { return(Json(new { success = false, msg = "IS_COMMENT" })); } string sessionCheckCode = Session["CheckCode"] == null ? null : Session["CheckCode"].ToString(); Session["CheckCode"] = null; if (sessionCheckCode == null) { return(Json(new { success = false, msg = "验证码已经过期,请刷新验证码!" })); } string checkCode = vld.Get("checkCode"); if (checkCode.ToLower() != sessionCheckCode.ToLower()) { return(Json(new { success = false, msg = "验证码错误!" })); } string content = vld.Get("content"); int score = vld.GetInt("score"); productBLL.AddComment(user.UserID, productId, content, score); return(Json(new { success = true })); }