Exemplo n.º 1
0
        public ActionResult CommentVote(int id)
        {
            Comment cm = CommentBll.GetFirstEntity(c => c.Id == id && c.Status == Status.Pended);

            if (Session["cm" + id] != null)
            {
                return(ResultData(null, false, "您刚才已经投过票了,感谢您的参与!"));
            }
            if (cm != null)
            {
                cm.VoteCount++;
                CommentBll.UpdateEntity(cm);
                Session["cm" + id] = id;
                bool b = CommentBll.SaveChanges() > 0;
                return(ResultData(null, b, b ? "投票成功" : "投票失败"));
            }
            return(ResultData(null, false, "非法操作"));
        }