public bool AddComment(T_Comment comment) { return commentData.Add(comment)>0; }
public ActionResult PostComment(CommentPostModel commentPost) { JsonViewResult json = new JsonViewResult() { Success = false }; if(!ModelState.IsValid) { json.Success = false; json.Message = "输入错误"; return Json(json, JsonRequestBehavior.AllowGet); } string verifyCode = Session["ValidateCode"] as string; if(verifyCode.ToLower()!=commentPost.VerifyCode) { json.Success = false; json.Message = "验证码输入错误"; return Json(json, JsonRequestBehavior.AllowGet); } var jokeinfo = jokeBusinessLogic.JokeDetailGet(commentPost.JokeID); T_Comment commentDomain = new T_Comment(); commentDomain.AddDate = DateTime.Now; commentDomain.Content = commentPost.Comment; commentDomain.Floor = jokeinfo.CommentCount+1; commentDomain.JokeId = commentPost.JokeID; commentDomain.UserID = user.UserId; jokeinfo.CommentCount = jokeinfo.CommentCount + 1; jokeBusinessLogic.UpdateJoke(jokeinfo); json.Success = jokeBusinessLogic.AddComment(commentDomain); return Json(json,JsonRequestBehavior.AllowGet); }