Exemple #1
0
        public JsonResult Vote(int messageId, int typeOfVote)
        {
            var loggedInUser = User.Identity.Name;

            switch (typeOfVote)
            {
            case 1:
                if (Karma.CommentKarma(loggedInUser) > 20)
                {
                    // perform upvoting or resetting
                    Voting.UpvoteSubmission(messageId, loggedInUser);
                }
                else if (Utils.User.TotalVotesUsedInPast24Hours(User.Identity.Name) < 11)
                {
                    // perform upvoting or resetting even if user has no CCP but only allow 10 votes per 24 hours
                    Voting.UpvoteSubmission(messageId, loggedInUser);
                }
                break;

            case -1:
                if (Karma.CommentKarma(loggedInUser) > 100)
                {
                    // perform downvoting or resetting
                    Voting.DownvoteSubmission(messageId, loggedInUser);
                }
                break;
            }
            return(Json("Voting ok", JsonRequestBehavior.AllowGet));
        }
Exemple #2
0
        public JsonResult Vote(int messageId, int typeOfVote)
        {
            lock (_locker)
            {
                int dailyVotingQuota            = Settings.DailyVotingQuota;
                var loggedInUser                = User.Identity.Name;
                var userCcp                     = Karma.CommentKarma(loggedInUser);
                var scaledDailyVotingQuota      = Math.Max(dailyVotingQuota, userCcp / 2);
                var totalVotesUsedInPast24Hours = UserHelper.TotalVotesUsedInPast24Hours(User.Identity.Name);

                switch (typeOfVote)
                {
                case 1:
                    if (userCcp >= 20)
                    {
                        if (totalVotesUsedInPast24Hours < scaledDailyVotingQuota)
                        {
                            // perform upvoting or resetting
                            Voting.UpvoteSubmission(messageId, loggedInUser, IpHash.CreateHash(UserHelper.UserIpAddress(Request)));
                        }
                    }
                    else if (totalVotesUsedInPast24Hours < 11)
                    {
                        // perform upvoting or resetting even if user has no CCP but only allow 10 votes per 24 hours
                        Voting.UpvoteSubmission(messageId, loggedInUser, IpHash.CreateHash(UserHelper.UserIpAddress(Request)));
                    }
                    break;

                case -1:
                    if (userCcp >= 100)
                    {
                        if (totalVotesUsedInPast24Hours < scaledDailyVotingQuota)
                        {
                            // perform downvoting or resetting
                            Voting.DownvoteSubmission(messageId, loggedInUser, IpHash.CreateHash(UserHelper.UserIpAddress(Request)));
                        }
                    }
                    break;
                }
                return(Json("Voting ok", JsonRequestBehavior.AllowGet));
            }
        }
Exemple #3
0
        public JsonResult Vote(int messageId, int typeOfVote)
        {
            string loggedInUser = User.Identity.Name;

            if (typeOfVote == 1)
            {
                // perform upvoting or resetting
                Voting.UpvoteSubmission(messageId, loggedInUser);
            }
            else if (typeOfVote == -1)
            {
                // ignore downvote if user link karma is below certain treshold
                if (Karma.CommentKarma(loggedInUser) > 100)
                {
                    // perform downvoting or resetting
                    Voting.DownvoteSubmission(messageId, loggedInUser);
                }
            }
            return(Json("Voting ok", JsonRequestBehavior.AllowGet));
        }
Exemple #4
0
        public JsonResult Vote(int messageId, int typeOfVote)
        {
            int dailyVotingQuota            = Convert.ToInt32(ConfigurationManager.AppSettings["dailyVotingQuota"]);
            var loggedInUser                = User.Identity.Name;
            var userCcp                     = Karma.CommentKarma(loggedInUser);
            var scaledDailyVotingQuota      = Math.Max(dailyVotingQuota, userCcp / 2);
            var totalVotesUsedInPast24Hours = Utils.User.TotalVotesUsedInPast24Hours(User.Identity.Name);

            switch (typeOfVote)
            {
            case 1:
                if (userCcp >= 20)
                {
                    if (totalVotesUsedInPast24Hours < scaledDailyVotingQuota)
                    {
                        // perform upvoting or resetting
                        Voting.UpvoteSubmission(messageId, loggedInUser);
                    }
                }
                else if (totalVotesUsedInPast24Hours < 11)
                {
                    // perform upvoting or resetting even if user has no CCP but only allow 10 votes per 24 hours
                    Voting.UpvoteSubmission(messageId, loggedInUser);
                }
                break;

            case -1:
                if (userCcp >= 100)
                {
                    if (totalVotesUsedInPast24Hours < scaledDailyVotingQuota)
                    {
                        // perform downvoting or resetting
                        Voting.DownvoteSubmission(messageId, loggedInUser);
                    }
                }
                break;
            }
            return(Json("Voting ok", JsonRequestBehavior.AllowGet));
        }