Beispiel #1
0
        ///<inheritdoc/>
        public void Update(int oldKey, AllVotes element)
        {
            var oldVote = this.GetOne(oldKey);

            oldVote = element;
            this.db.SaveChanges();
        }
Beispiel #2
0
 ///<inheritdoc/>
 public bool UpdateVote(int oldId, AllVotes newVote)
 {
     try
     {
         this.allVotesRepo.Update(oldId, newVote);
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Beispiel #3
0
        public void Reset(IEnumerable <Song> songs, Song currentlyPlaying)
        {
            Logger.LogDebug("PartyService: Reset");
            Console.WriteLine("PartyService: Reset");

            AllSongs.Clear();
            foreach (Song song in songs)
            {
                AllSongs.Add(song);
            }

            AllVotes.Clear();
            CanVote          = true;
            CurrentlyPlaying = currentlyPlaying;

            SongListingStream.OnNext(GenerateSongListing(AllSongs, CurrentlyPlaying));
            VotingResultsStream.OnNext(GenerateVotingResults(AllSongs, AllVotes, CanVote));
        }
Beispiel #4
0
        /// <summary>
        /// Increments the associated values in the AllVotes entry, based on what this OneVote has voted for.
        /// </summary>
        /// <param name="vote">The OneVote object to be used to update the values in the AllVotes entry that belongs to it</param>
        void AddUsersChoiceToAllVotes(OneVote vote)
        {
            AllVotes allVoteToSaveChoise = this.allVotesLogic.GetOneVote(vote.VoteID);

            switch (vote.Choice)
            {
            case 0:
                allVoteToSaveChoise.YesVotes += 1;
                this.allVotesLogic.UpdateVote(allVoteToSaveChoise.VoteID, allVoteToSaveChoise);
                break;

            case 1:
                allVoteToSaveChoise.NoVotes += 1;
                this.allVotesLogic.UpdateVote(allVoteToSaveChoise.VoteID, allVoteToSaveChoise);
                break;

            default:
                allVoteToSaveChoise.AbsentionVotes += 1;
                this.allVotesLogic.UpdateVote(allVoteToSaveChoise.VoteID, allVoteToSaveChoise);
                break;
            }
        }
Beispiel #5
0
 public void UpdateVote(int oldId, [FromBody] AllVotes vote)
 {
     this.allVotesLogic.UpdateVote(oldId, vote);
 }
Beispiel #6
0
 public ActionResult CreateVote([FromBody] AllVotes vote)
 {
     this.allVotesLogic.CreateVote(vote);
     return(Ok());
 }
Beispiel #7
0
 ///<inheritdoc/>
 public void Add(AllVotes element)
 {
     db.Add(element);
     db.SaveChanges();
 }
Beispiel #8
0
 ///<inheritdoc/>
 public bool CreateVote(AllVotes vote)
 {
     this.allVotesRepo.Add(vote);
     return(true);
 }