Esempio n. 1
0
        public ActionResult VoteReset(int id, int change)
        {
            var post = blogRepository.GetPost(id);
            post.Votes = post.Votes + change;

            Vote vote = new Vote()
            {
                PostId = id,
                Votes = 0
            };
            if (Request.IsAuthenticated)
            {
                var uName = User.Identity.Name;
                vote.Username = uName;
            }
            else
            {
                int sId = Convert.ToInt32(Session["UserId"]);
                vote.SessionId = sId;
            }
            blogRepository.AddVote(vote);
            blogRepository.Save();
            return Json(post);
        }
Esempio n. 2
0
 public void AddVote(Vote vote)
 {
     db.Votes.Add(vote);
 }