Ejemplo n.º 1
0
        private Control GenerateReport(string politicianKey, string issueKey,
                                       out int answerCount, string issueDescription = null)
        {
            answerCount = 0;
            if (issueDescription == null)
            {
                issueDescription = VotePage.GetPageCache()
                                   .Issues.GetIssue(issueKey);
            }

            _QuestionsTable = Questions.GetNonOmittedDataByIssueKey(issueKey);
            _Answers        = Issues.GetPoliticianIssuePageIssueData(politicianKey, issueKey);
            var unansweredQuestions = new List <QuestionsRow>(_QuestionsTable);

            _HtmlTable =
                new HtmlTable {
                CellSpacing = 0, CellPadding = 0
            }.AddCssClasses("tablePage");

            var tr = new HtmlTableRow().AddTo(_HtmlTable, "trPoliticianIssueHeading");

            new HtmlTableCell {
                InnerHtml = issueDescription
            }.AddTo(tr,
                    "tdPoliticianIssueHeadingLeft");

            new HtmlTableCell {
                InnerHtml = "Positions and Views"
            }.AddTo(tr,
                    "tdPoliticianIssueHeadingRight");
            foreach (var question in _QuestionsTable)
            {
                var answer = _Answers.Rows.OfType <DataRow>()
                             .FirstOrDefault(row => row.QuestionKey()
                                             .IsEqIgnoreCase(question.QuestionKey));
                if (answer == null)
                {
                    continue;
                }

                answerCount++;
                unansweredQuestions.Remove(question);

                ReportAnswer(question, answer);
            }

            if (unansweredQuestions.Count > 0)
            {
                tr = new HtmlTableRow().AddTo(_HtmlTable, "trNoResponsesHeading");
                new HtmlTableCell
                {
                    InnerHtml =
                        "These are available issue topics for which there were no responses.",
                    ColSpan = 2
                }.AddTo(tr, "tdNoResponsesHeading");

                foreach (var question in unansweredQuestions)
                {
                    ReportUnansweredQuestion(question);
                }
            }

            return(_HtmlTable);
        }