Exemplo n.º 1
0
        private HtmlTable CreateBioTable()
        {
            var htmlTable =
                new HtmlTable {
                CellSpacing = 0, CellPadding = 0, Border = 0
            }.AddCssClasses(
                "bioTable");

            // Age
            //
            var tr = new HtmlTableRow().AddTo(htmlTable,
                                              "trPoliticianInfoContact trPoliticianInfoContactAge");
            var td = new HtmlTableCell().AddTo(tr, "tdPoliticianInfoContactHeading");

            new HtmlSpan {
                InnerHtml = "Age:"
            }.AddTo(td);
            new HtmlTableCell {
                InnerHtml = _PoliticianInfo.Age()
            }.AddTo(tr,
                    "tdPoliticianInfoContactDetail");

            // Party
            //
            tr = new HtmlTableRow().AddTo(htmlTable, "trPoliticianInfoContact");
            td = new HtmlTableCell().AddTo(tr, "tdPoliticianInfoContactHeading");
            new HtmlSpan {
                InnerHtml = "Party:"
            }.AddTo(td);
            td = new HtmlTableCell().AddTo(tr, "tdPoliticianInfoContactDetail");
            CreatePartyAnchor()
            .AddTo(td);

            // Phone
            //
            tr = new HtmlTableRow().AddTo(htmlTable, "trPoliticianInfoContact");
            td = new HtmlTableCell().AddTo(tr, "tdPoliticianInfoContactHeading");
            new HtmlSpan {
                InnerHtml = "Phone:"
            }.AddTo(td);
            var phone = _PoliticianInfo.PublicPhone();

            new HtmlTableCell
            {
                InnerHtml = string.IsNullOrWhiteSpace(phone) ? "n/a" : phone
            }.AddTo(tr,
                    "tdPoliticianInfoContactDetail");

            // Address
            //
            tr = new HtmlTableRow().AddTo(htmlTable, "trPoliticianInfoContact");
            td = new HtmlTableCell().AddTo(tr, "tdPoliticianInfoContactHeading");
            new HtmlSpan {
                InnerHtml = "Address:"
            }.AddTo(td);
            var address = _PoliticianInfo.PublicAddress();

            if (!string.IsNullOrWhiteSpace(address))
            {
                address += "<br />";
            }
            address += _PoliticianInfo.PublicCityStateZip();
            new HtmlTableCell
            {
                InnerHtml = string.IsNullOrWhiteSpace(address) ? "n/a" : address
            }.AddTo(
                tr, "tdPoliticianInfoContactDetail");

            // Social media
            //
            tr = new HtmlTableRow().AddTo(htmlTable, "trPoliticianInfoContact");
            td = new HtmlTableCell().AddTo(tr, "tdPoliticianInfoContactHeading");
            new HtmlSpan {
                InnerHtml = "&nbsp;"
            }.AddTo(td);
            var webUrl = _PoliticianInfo.PublicWebAddress();

            td = new HtmlTableCell().AddTo(tr,
                                           "tdPoliticianInfoContactDetail socialMedia");
            new HtmlBreak(2).AddTo(td);
            if (!string.IsNullOrWhiteSpace(webUrl))
            {
                var span  = new HtmlSpan().AddTo(td, "TWebsite");
                var title = Politicians.FormatName(_PoliticianInfo) + "'s Website";
                new HtmlAnchor
                {
                    HRef      = VotePage.NormalizeUrl(webUrl),
                    Title     = title,
                    Target    = "view",
                    InnerHtml = "Website"
                }.AddTo(span);
                new HtmlBreak(2).AddTo(td);
            }
            SocialMedia.GetAnchors(_PoliticianInfo)
            .AddTo(td);

            return(htmlTable);
        }
Exemplo n.º 2
0
        protected void FormatPoliticianRow(DataRow row)
        {
            var politicianKey = row.PoliticianKey();

            var tr = new HtmlTableRow().AddTo(CurrentHtmlTable, "trReportDetail");

            CreatePoliticianImageTag(politicianKey, ImageSize100).AddTo(
                new HtmlTableCell().AddTo(tr, "tdReportDetailLargeBold"));

            // Information We Have
            //var infoLines = new List<string>();

            var tdInfo = new HtmlTableCell().AddTo(tr, "tdReportDetailSmall");

            // Age, Phone, Address, Social Media
            var politicianAge = row.Age();

            if (IsNullOrWhiteSpace(politicianAge))
            {
                AddItem(tdInfo, "No DOB to compute age", Options.Strong | Options.Em);
                new HtmlBreak().AddTo(tdInfo);
            }
            else
            {
                AddItem(tdInfo, "Age " + politicianAge);
            }

            new HtmlBreak().AddTo(tdInfo);
            var politicianPhone = row.PublicPhone();

            if (IsNullOrWhiteSpace(politicianPhone))
            {
                AddItem(tdInfo, "No Phone", Options.Strong);
            }
            else
            {
                AddItem(tdInfo, politicianPhone.NormalizePhoneNumber(), Options.NoBreak);
            }

            new HtmlBreak().AddTo(tdInfo);
            var politicianAddress = row.PublicAddress();

            if (IsNullOrWhiteSpace(politicianAddress))
            {
                AddItem(tdInfo, "No Address", Options.Strong);
            }
            else
            {
                AddItem(tdInfo, politicianAddress);
                new HtmlBreak().AddTo(tdInfo);
                AddItem(tdInfo, row.PublicCityStateZip());
            }

            var socialMediaAnchors = SocialMedia.GetAnchors(row, out var socialMediaCount);

            new HtmlBreak(2).AddTo(tdInfo);
            if (socialMediaCount == 0)
            {
                AddItem(tdInfo, "No social media links or email address", Options.Strong | Options.Em);
                new HtmlBreak().AddTo(tdInfo);
            }
            else
            {
                socialMediaAnchors.AddTo(tdInfo);
            }

            // Web address
            new HtmlBreak().AddTo(tdInfo);
            var webAddress = row.PublicWebAddress();

            if (IsNullOrWhiteSpace(webAddress))
            {
                AddItem(tdInfo, "No web address", Options.Strong | Options.Em);
            }
            else
            {
                new HtmlAnchor
                {
                    HRef      = VotePage.NormalizeUrl(webAddress),
                    Target    = "website",
                    InnerHtml = "Have web address"
                }
            }.AddTo(tdInfo);
Exemplo n.º 3
0
        private HtmlControl ReportCandidate(DataRow candidate)
        {
            var info = new HtmlDiv().AddCssClasses("info");

            var name          = new HtmlP().AddTo(info, "name");
            var isPrimary     = Elections.IsPrimaryElection(candidate.ElectionKey());
            var isNonPartisan =
                Elections.GetNationalPartyCode(candidate.ElectionKey()) == "X";

            FormatCandidate(candidate, true, (!isPrimary || isNonPartisan) &&
                            !candidate.IsRunningMate())
            .AddTo(name);

            if (candidate.IsWinner() && !candidate.IsRunningMate())
            {
                info.AddCssClasses("winner");
                new HtmlDiv()
                .Attribute("title", "Winner")
                .AddTo(info, "winner-icon");
            }

            new HtmlImage
            {
                Src = VotePage.GetPoliticianImageUrl(candidate.PoliticianKey(), 75)
            }.AddTo(
                info, "rounded-border headshot");

            var rightSide = new HtmlDiv().AddTo(info, "right-side");

            FormatCandidatePhone(candidate)
            .AddTo(rightSide);

            FormatCandidateWebsite(candidate)
            .AddTo(rightSide);

            SocialMedia.GetAnchors(candidate)
            .AddCssClasses("social")
            .AddTo(rightSide);

            var address      = candidate.PublicAddress();
            var cityStateZip = candidate.PublicCityStateZip();

            if (!string.IsNullOrWhiteSpace(address) &&
                !string.IsNullOrWhiteSpace(cityStateZip))
            {
                var addressTag = new HtmlDiv().AddTo(rightSide, "address");
                new HtmlP {
                    InnerText = address
                }.AddTo(addressTag);
                new HtmlP {
                    InnerText = cityStateZip
                }.AddTo(addressTag);
            }

            var age = candidate.Age();

            if (!string.IsNullOrWhiteSpace(age))
            {
                var ageTag = new HtmlDiv().AddTo(rightSide, "age");
                new HtmlSpan {
                    InnerText = "Age: "
                }.AddTo(ageTag);
                new LiteralControl(age).AddTo(ageTag);
            }

            ClearBoth()
            .AddTo(info);

            return(info);
        }