コード例 #1
0
        public VoteDTO Get(int ID)
        {
            VoteEntity getvote = ur.Get(ID);
            VoteDTO    vote    = Mapper.Map <VoteDTO>(getvote);

            return(vote);
        }
コード例 #2
0
        public Dashboard GetDashboard()
        {
            var hasVotingStarted = VoteRepository.HasVotingStarted();

            var dashboard = new Dashboard
            {
                FaceOff        = ChiliRepository.GetFaceOffChiliCards(),
                LadderClimbers = ChiliRepository.GetLadderClimbers(),
                TotalVotes     = VoteRepository.Get().Count,
                ChiliChart     = new ChiliChart
                {
                    Columns = ChiliRepository.GetChiliChartColumns()
                },
                VotingStarted = hasVotingStarted
            };

            if (!hasVotingStarted)
            {
                dashboard.Contenders = ChiliRepository.GetChilis().Select(chili => new ChiliCard
                {
                    Description = chili.Description,
                    ImageUrl    = chili.ImageUrl,
                    Subtitle    = chili.Contestant,
                    Title       = chili.Name,
                    Votes       = 0
                }).ToList();
            }

            return(dashboard);
        }
コード例 #3
0
        public async Task VoteRepository_CRD_Tests()
        {
            const int firstWarId  = 1234;
            const int secondWarId = 5678;
            var       sqlServerConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["WarDb"].ConnectionString;
            var       repository = new VoteRepository(sqlServerConnectionString);

            var firstVote = await CreateVote(repository, firstWarId);

            var firstVoteWrongWarId = await repository.Get(secondWarId, firstVote.MatchId);

            firstVoteWrongWarId.Should().BeNullOrEmpty();

            var secondVote = await CreateVote(repository, firstWarId);

            var thirdVote = await CreateVote(repository, secondWarId);

            var firstWarCollection = await repository.GetAll(firstWarId);

            VerifyVoteInCollection(firstWarCollection, firstVote);
            VerifyVoteInCollection(firstWarCollection, secondVote);
            VerifyVoteNotInCollection(firstWarCollection, thirdVote);

            var secondWarCollection = await repository.GetAll(secondWarId);

            VerifyVoteNotInCollection(secondWarCollection, firstVote);
            VerifyVoteNotInCollection(secondWarCollection, secondVote);
            VerifyVoteInCollection(secondWarCollection, thirdVote);

            await VerifyVoteDelete(repository, firstWarId, firstVote.MatchId);
            await VerifyVoteDelete(repository, firstWarId, secondVote.MatchId);
            await VerifyVoteDelete(repository, secondWarId, thirdVote.MatchId);
        }
コード例 #4
0
        private static async Task VerifyVoteDelete(VoteRepository repository, int warId, Guid matchId)
        {
            await repository.Delete(warId, matchId);

            var afterDelete = await repository.Get(warId, matchId);

            afterDelete.Should().BeNullOrEmpty();
        }
コード例 #5
0
        private static async Task <Vote> CreateVote(VoteRepository repository, int warId)
        {
            var request = CreateTestVote();
            await repository.Add(warId, request);

            var votes = await repository.Get(warId, request.MatchId);

            VerifyRequestInVotesCollection(votes, request);
            return(votes.Single(x => x.MatchId == request.MatchId));
        }