예제 #1
0
        public SongVote AddSongVote(SongVote vote)
        {
            if (CanVote)
            {
                AllVotes[vote.VoterId] = vote.SongId;
                VotingResultsStream.OnNext(GenerateVotingResults(AllSongs, AllVotes, CanVote));
                return(vote);
            }

            return(new SongVote {
                VoterId = vote.VoterId, SongId = AllVotes[vote.VoterId]
            });
        }
예제 #2
0
        public PartyMutations(IPartyService partyService)
        {
            Name = "Mutation";

            Field <SongVoteGraphType>("addVote",
                                      arguments: new QueryArguments(
                                          new QueryArgument <SongVoteInputGraphType> {
                Name = "vote"
            }
                                          ),
                                      resolve: context =>
            {
                SongVote receivedVote = context.GetArgument <SongVote>("vote");
                SongVote savedVote    = partyService.AddSongVote(receivedVote);
                return(savedVote);
            }
                                      );
        }