public void IntegrateVotesForDay(DateTime dayToImportFor)
        {
            _dayToImportFor = dayToImportFor;

            var voteInformationUrl        = GetVoteInformationUrl(_dayToImportFor);
            var voteInformationPdfText    = PdfHelper.GetTextFromPDF(voteInformationUrl, 2);
            var voteInformationPdf        = new VoteInformationPdf(voteInformationPdfText, _dayToImportFor);
            var voteInformationIntegrator = new VoteInformationIntegrator(_context);

            voteInformationIntegrator.IntegrateVoteInformation(voteInformationPdf);

            var voteResultUrl        = GetVoteResultUrl(_dayToImportFor);
            var voteResultPdfText    = PdfHelper.GetTextFromPDF(voteResultUrl, 2);
            var voteResultPdf        = new VoteResultPdf(voteResultPdfText, _dayToImportFor);
            var voteResultIntegrator = new VoteResultIntegrator(_context, _dayToImportFor);

            voteResultIntegrator.IntegrateVoteResult(voteResultPdf);
        }
Exemplo n.º 2
0
        public void IntegrateVoteResult(VoteResultPdf pdf)
        {
            while (pdf.HasMoreVotes())
            {
                pdf.GoToNextVote();

                var voteCode = pdf.GetVoteCode();
                var vote     = _votes.FirstOrDefault(x => x.Code == voteCode);
                if (vote == null)
                {
                    continue;
                }

                var approvedVoterNames  = pdf.GetApprovedVoterNames();
                var rejectedVoterNames  = pdf.GetRejectedVoterNames();
                var abstainedVoterNames = pdf.GetAbstainedVoterNames();

                IntegrateResultType(approvedVoterNames, vote.VoteId, VoteType.Approve);
                IntegrateResultType(rejectedVoterNames, vote.VoteId, VoteType.Reject);
                IntegrateResultType(abstainedVoterNames, vote.VoteId, VoteType.Abstain);

                _context.SaveChanges();
            }
        }