Exemple #1
0
        public void LogVoteIncident(VotingIncident incident)
        {
            int lastTick = Find.TickManager.TicksGame;

            lastID = lastID + 1;
            VoteIDs.Add(lastID, incident.defName);
            VoteHistory.Add(lastID, lastTick);
            previousCategory = incident.eventCategory;
            previousType     = incident.eventType;
            lastFiredTick    = lastTick;
        }
Exemple #2
0
        public void CleanListOfExpiredVotes()
        {
            List <int> idsToRemove = new List <int>();

            foreach (KeyValuePair <int, string> pair in VoteIDs)
            {
                if (VoteHistory[pair.Key] >= VotingPeriodDays * GenDate.TicksPerDay)
                {
                    idsToRemove.Add(pair.Key);
                }
            }

            foreach (int id in idsToRemove)
            {
                VoteIDs.Remove(id);
                VoteHistory.Remove(id);
            }
        }
 //unvote a proposal
 // DELETE api/votehistory/5
 public HttpResponseMessage Delete(ViewUnvote unvote)
 {
     if (ModelState.IsValid)
     {
         HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK);
         VoteHistory         history  = _db.VoteHistory.Find(unvote.Id);
         if (history != null)
         {
             _db.VoteHistory.Remove(history); //remove vote history
             Models.User user = _db.User.FirstOrDefault(c => c.UserId == WebSecurity.CurrentUserId);
             user.RemainingVotes++;
             Models.Proposal proposal = _db.Proposal.FirstOrDefault(c => c.Id == unvote.ProposalId);
             proposal.Votes--;
             _db.SaveChanges();
             return(response);
         }
         return(response = Request.CreateResponse(HttpStatusCode.NotModified));
     }
     else
     {
         return(Request.CreateResponse(HttpStatusCode.BadRequest));
     }
 }
Exemple #4
0
 public void LogVoteIncident(VotingIncident incident)
 {
     lastID = lastID + 1;
     VoteIDs.Add(lastID, incident.defName);
     VoteHistory.Add(lastID, Find.TickManager.TicksGame);
 }