Ejemplo n.º 1
0
        public ActionResult DownVote(Vote vote)
        {
            string VoteMessage = "";
            string loggedin = User.Identity.GetUserId();
            var curvotestatus = (from v in db.Vote where v.UserID == loggedin && v.ReplyID == vote.ReplyID select v).Count();
            var curvoter = (from v in db.Users where v.Id == vote.UserID select v).FirstOrDefault();
            if (curvotestatus > 0)
            {
                VoteMessage = "You have already voted";
            }
            else
            {
                db.Vote.Add(vote);
                if (loggedin != curvoter.Id)
                {
                    curvoter.Points = curvoter.Points - 2;
                }
                db.SaveChanges();
                VoteMessage = "Voted!!!";
            }

            return Json(VoteMessage, JsonRequestBehavior.AllowGet);
        }
Ejemplo n.º 2
0
 public ActionResult UpVote(Vote vote)
 {
     var ExMsg = "Nothing";
     try
     {
         string VoteMessage = "";
         string loggedin = User.Identity.GetUserId();
         var curvotestatus = (from v in db.Vote where v.UserID == loggedin && v.ReplyID == vote.ReplyID select v).Count();
         var curvoter = (from v in db.Users where v.Id == vote.UserID select v).FirstOrDefault();
         if (curvotestatus > 0)
         {
             VoteMessage = "You have already voted";
         }
         else
         {
             db.Vote.Add(vote);
             if (loggedin != curvoter.Id)
             {
                 curvoter.Points = curvoter.Points + 2;
             }
             db.SaveChanges();
             VoteMessage = "Voted!";
         }
     }
     catch (Exception ex) {
         ExMsg = ex.Message;
     }
     return Json(ExMsg, JsonRequestBehavior.AllowGet);
 }