private void ChangeVoteValue(Vote vote, VoteViewModel model, int newVoteValue)
        {
            if (vote.Value == -newVoteValue)
            {
                vote.Value = 0;
            }
            else if (vote.Value == 0)
            {
                vote.Value = newVoteValue;
            }

            this.votes.Update(vote);
            this.votes.SaveChanges();
            model.PostVotes = this.GetPostVotes(model.PostId);
        }
        public PartialViewResult UpdateVotesPositive(int currentPostId)
        {
            var currentUserId = this.User.Identity.GetUserId();
            var currentPost = this.posts.All().Where(p => p.Id == currentPostId).FirstOrDefault();

            var vote = new Vote()
            {
                IsPositive = true,
                AuthorId = currentUserId
            };

            this.votes.Add(vote);
            this.votes.SaveChanges();
            currentPost.Votes.Add(vote);
            this.posts.SaveChanges();

            var postToUpdate = this.posts.All().Where(p => p.Id == currentPostId).Project().To<IndexBlogPostViewModel>().FirstOrDefault();

            return PartialView("_Vote", postToUpdate);
        }
        private Vote CreateVote(VoteViewModel model, string userId, Vote vote, int voteValue)
        {
            vote = new Vote()
            {
                PostId = model.PostId,
                Value = voteValue,
                AuthorId = userId
            };

            model.PostVotes = model.PostVotes.HasValue ? model.PostVotes + voteValue : voteValue;
            this.votes.Add(vote);
            this.votes.SaveChanges();
            return vote;
        }