Beispiel #1
0
        public void IntegrateVoteInformation(VoteInformationPdf pdf)
        {
            while (pdf.HasMoreVotes())
            {
                pdf.GoToNextVote();

                var voteName = pdf.GetVoteName();
                var voteCode = pdf.GetVoteCode();

                if (_context.Votes.Any(x => x.Code == voteCode))
                {
                    continue;
                }

                var vote = new Vote
                {
                    VoteId             = Guid.NewGuid(),
                    Name               = voteName,
                    Code               = voteCode,
                    Date               = pdf.Date,
                    VoteNumberOfTheDay = pdf.GetNumberOfVoteOfTheDayOfCurrentVote()
                };
                _context.Add(vote);
            }
            _context.SaveChanges();
        }
        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);
        }