Пример #1
0
            public void Generate(ElectionReportResponsive electionReport, string electionKey,
                                 bool isForAllStatesReport = false)
            {
                ElectionReport       = electionReport;
                ElectionKey          = electionKey;
                StateCode            = Elections.GetStateCodeFromKey(electionKey);
                CountyCode           = Elections.GetCountyCodeFromKey(electionKey);
                LocalCode            = Elections.GetLocalCodeFromKey(electionKey);
                IsForAllStatesReport = isForAllStatesReport;

                var offices = GetOffices()
                              .Where(g => g.First().ElectionsPoliticianKey() != null)
                              .ToList();

                if (offices.Count <= 0)
                {
                    return;
                }
                if ((electionReport.ReportUser == ReportUser.Public) &&
                    Elections.IsPrimaryElection(electionKey))
                {
                    offices = FilterUncontestedOffices(offices)
                              .ToList();
                }

                Control container;

                // only create a category wrapper if more than one office
                if ((offices.Count > 1) || isForAllStatesReport)
                {
                    // ReSharper disable once PossibleNullReferenceException
                    (new HtmlDiv().AddTo(ElectionReport.ReportContainer, "category-title accordion-header")
                     as HtmlGenericControl).InnerHtml = GetCategoryTitle();
                    container = new HtmlDiv().AddTo(ElectionReport.ReportContainer,
                                                    "category-content accordion-content");
                }
                else
                {
                    container = ElectionReport.ReportContainer;
                }

                foreach (var office in offices)
                {
                    var politicians = office.ToList();
                    var officeInfo  = politicians[0];

                    var officeContent = new HtmlDiv();
                    ElectionReport.CreateOfficeTitle(container, officeContent, politicians,
                                                     GetOfficeTitle(officeInfo));
                    officeContent.AddTo(container, "office-content accordion-content");
                    var isRunningMateOffice = officeInfo.IsRunningMateOffice() &&
                                              !Elections.IsPrimaryElection(electionKey);
                    ReportOffice(officeContent, isRunningMateOffice, politicians,
                                 ElectionReport._DataManager, false, false,
                                 ElectionReport.ReportUser == ReportUser.Master);
                }
            }
Пример #2
0
        private static void AddIssue(DataRow candidate, QuestionEntry question)
        {
            var item = new HtmlDiv();

            item.AddTo(question.Container, "info-item issue-item");
            var row =
                question.QuestionGroup.FirstOrDefault(
                    r => r.PoliticianKey().IsEqIgnoreCase(candidate.PoliticianKey()));

            if (row == null) // no answer
            {
                item.AddCssClasses("empty-item");
            }
            else
            {
                item.InnerText = row.Answer();
            }
        }
Пример #3
0
            internal void Initialize(SecurePage page)
            {
                _TabLabel =
                    page.Master.FindMainContentControl("TabMain" + TabName) as HtmlAnchor;
                _Button         = page.Master.FindMainContentControl("Button" + TabName);
                _DescriptionTag =
                    page.Master.FindMainContentControl("Description" + TabName) as
                    HtmlInputHidden;

                Debug.Assert(_TabLabel != null, "_TabLabel != null");
                var li     = _TabLabel.Parent as HtmlGenericControl;
                var astDiv = new HtmlDiv();

                astDiv.Attributes.Add("class", "tab-ast tiptip");
                if (TabAsteriskToolTip != null)
                {
                    astDiv.Attributes.Add("title", TabAsteriskToolTip);
                }
                else
                {
                    astDiv.Attributes.Add("title",
                                          "There are unsaved changes on the " + _TabLabel.InnerText + " tab");
                }
                astDiv.AddTo(li);
                if (_Button != null)
                {
                    if (ButtonToolTip != null)
                    {
                        _Button.SetToolTip(ButtonToolTip);
                    }
                    else
                    {
                        _Button.SetToolTip("Update " + _TabLabel.InnerText);
                    }
                }
                if (_DescriptionTag != null)
                {
                    _DescriptionTag.Value = _TabLabel.InnerText;
                }
            }
            public void Generate(ElectionReportResponsive electionReport, string electionKey,
                                 bool isForAllStatesReport = false)
            {
                ElectionReport = electionReport;
                ElectionKey    = electionKey;
                StateCode      = Elections.GetStateCodeFromKey(electionKey);
                CountyCode     = Elections.GetCountyCodeFromKey(electionKey);
                LocalKey       = Elections.GetLocalKeyFromKey(electionKey);
                var counties           = LocalIdsCodes.FindCountiesWithNames(StateCode, LocalKey);
                var isMultiCountyLocal = counties.Length > 1;

                IsForAllStatesReport = isForAllStatesReport;

                var offices = GetOffices()
                              .Where(g => g.First().ElectionsPoliticianKey() != null)
                              .ToList();

                if (offices.Count <= 0)
                {
                    return;
                }
                if (Elections.IsPrimaryElection(electionKey))
                {
                    offices = FilterUncontestedOffices(offices)
                              .ToList();
                }

                Control container;

                // only create a category wrapper if more than one office, or isMultiCountyLocal
                if (isMultiCountyLocal || offices.Count > 1 || isForAllStatesReport)
                {
                    // ReSharper disable once PossibleNullReferenceException
                    var title = new PlaceHolder();
                    // ReSharper disable once PossibleNullReferenceException
                    (new HtmlSpan().AddTo(title) as HtmlGenericControl).InnerText = GetCategoryTitle();
                    if (isMultiCountyLocal)
                    {
                        var allCounties =
                            LocalIdsCodes.FormatAllCountyNames(StateCode, LocalKey, true);
                        // ReSharper disable once PossibleNullReferenceException
                        (new HtmlP().AddTo(title) as HtmlGenericControl)
                        .InnerText = $"Parts of this local district are in {allCounties}";
                    }
                    // ReSharper disable once PossibleNullReferenceException
                    new HtmlDiv().AddTo(ElectionReport.ReportContainer, "category-title accordion-header")
                    .Controls.Add(title);
                    container = new HtmlDiv().AddTo(ElectionReport.ReportContainer,
                                                    "category-content accordion-content");
                }
                else
                {
                    container = ElectionReport.ReportContainer;
                }

                foreach (var office in offices)
                {
                    var politicians = office.ToList();
                    var officeInfo  = politicians[0];

                    var officeContent = new HtmlDiv();
                    CreateOfficeTitle(container, officeContent, politicians,
                                      GetOfficeTitle(officeInfo));
                    officeContent.AddTo(container, "office-content accordion-content");
                    //var isRunningMateOffice = officeInfo.IsRunningMateOffice() &&
                    //  !Elections.IsPrimaryElection(electionKey);
                    var isRunningMateOffice = Offices.IsRunningMateOfficeInElection(electionKey,
                                                                                    officeInfo.OfficeKey());
                    ReportOffice(officeContent, isRunningMateOffice, politicians,
                                 ElectionReport._DataManager);
                }
            }