Esempio n. 1
0
        private static IEnumerable <LinkInfo> GetStateLinks(string stateCode,
                                                            bool includeFutureElections)
        {
            var linkList = new List <LinkInfo>();

            if (StateCache.IsValidStateCode(stateCode))
            {
                var table =
                    Elections.GetViewableDisplayDataByStateCode(stateCode);

                var now = DateTime.UtcNow;
                foreach (var row in table)
                {
                    if (includeFutureElections || row.ElectionDate < now)
                    {
                        var linkInfo = new LinkInfo(row)
                        {
                            HRef = UrlManager.GetElectionPageUri(row.ElectionKey, false, false, true)
                        };
                        linkList.Add(linkInfo);
                    }
                }
            }

            return(linkList);
        }
Esempio n. 2
0
        private void HandleElectionPage()
        {
            var electionKey = MemCache.IsValidElection(GetQueryParm("Election"))
        ? GetQueryParm("Election")
        : FixElectionKeyFromQueryString();

            var forIFrame = OriginalUri.AbsolutePath.ToLower() == "/electionforiframe.aspx";

            if (!string.IsNullOrEmpty(electionKey))
            {
                var stateCode = Elections.GetValidatedStateCodeFromKey(electionKey);
                if (string.IsNullOrEmpty(stateCode))
                {
                    // Build normalized uri without state
                    NormalizedUri   = UrlManager.GetElectionPageUri(electionKey, false, forIFrame);
                    _IsCanonicalUsa = true;
                }
                else if (StateCache.IsValidStateCode(stateCode))
                {
                    // Build normalized uri with state
                    NormalizedUri = UrlManager.GetElectionPageUri(stateCode, electionKey, false, forIFrame);
                }
                else
                {
                    ErrorMessage = "Invalid_StateCode";
                }
            }
            else
            {
                ErrorMessage = "Invalid_ElectionKey|StateCode";
            }
        }
Esempio n. 3
0
        private static List <LinkInfo> GetRecentSampleBallotLinks(LocationCookies cookies)
        {
            var linkList = new List <LinkInfo>();

            if (StateCache.IsValidStateCode(cookies.State))
            {
                var table =
                    Elections.GetViewableDisplayDataByStateCode(cookies.State);

                foreach (var row in table)
                {
                    var linkInfo = new LinkInfo(row)
                    {
                        HRef =
                            UrlManager.GetBallotPageUri(row.ElectionKey, cookies.Congress,
                                                        cookies.StateSenate, cookies.StateHouse, cookies.County, cookies.District,
                                                        cookies.Place, cookies.Elementary, cookies.Secondary, cookies.Unified,
                                                        cookies.CityCouncil, cookies.CountySupervisors,
                                                        cookies.SchoolDistrictDistrict, null)
                    };
                    linkList.Add(linkInfo);
                    // go back to most recent general or offyear election
                    if (row.ElectionType == "G" || row.ElectionType == "O")
                    {
                        break;
                    }
                }
            }

            return(linkList);
        }
Esempio n. 4
0
        private void HandleOfficialsPage()
        {
            var reportCode = string.Empty;

            if (StateCache.IsValidStateOrFederalCode(GetQueryParm("Report"), false))
            {
                reportCode = GetQueryParm("Report")
                             .ToUpper();
            }
            else
            {
                var stateCode = UrlManager.FindStateCode();
                if (StateCache.IsValidStateCode(stateCode) ||
                    StateCache.IsValidFederalCode(stateCode, false))
                {
                    reportCode = stateCode;
                }
            }

            if (!string.IsNullOrEmpty(reportCode))
            {
                NormalizedUri = UrlManager.GetOfficialsPageUri(reportCode,
                                                               GetQueryParm("County"), GetQueryParm("Local"));
                _IsCanonicalUsa = !StateCache.IsValidStateCode(reportCode);
            }
            else
            {
                ErrorMessage = "The Report code could not be identified.";
            }
        }
Esempio n. 5
0
        public static Uri GetElectionPageUri(string state, string election, bool openAll = false, bool forIFrame = false)
        {
            var page = forIFrame
        ? "ElectionForIFrame.aspx"
        : "Election.aspx";

            if (StateCache.IsValidStateCode(state))
            {
                var qsc = new QueryStringCollection();
                AddNonEmptyParm(qsc, "State", state);
                AddNonEmptyParm(qsc, "Election", election);
                if (openAll)
                {
                    AddNonEmptyParm(qsc, "openall", "Y");
                }
                return(GetStateUri(state, page, qsc));
            }
            else
            {
                var qsc = new QueryStringCollection();
                AddNonEmptyParm(qsc, "Election", election);
                if (openAll)
                {
                    AddNonEmptyParm(qsc, "openall", "Y");
                }
                return(GetStateUri(G.State_Code(), page, qsc));
            }
        }
Esempio n. 6
0
 private void FillInStateLink()
 {
     new HtmlAnchor
     {
         InnerText = $"Go to {StateCache.GetStateName(_StateCode)} State Election",
         HRef      = UrlManager.GetElectionPageUri(Elections.GetStateElectionKeyFromKey(_ElectionKey)).ToString()
     }.AddTo(HigherLevelLinks, "state-link");
 }
Esempio n. 7
0
        private void AnalyzeElectoralClass()
        {
            string titleContentDescription;
            var    metaContentLocation = Empty;

            switch (_ElectoralClass)
            {
            case ElectoralClass.USPresident:
                titleContentDescription = "Current US President and Vice President";
                break;

            case ElectoralClass.USSenate:
                titleContentDescription = "Current US Senators";
                break;

            case ElectoralClass.USHouse:
                titleContentDescription = "Current US House Members";
                break;

            case ElectoralClass.USGovernors:
                titleContentDescription = "Current State Governors and Lieutenant Governors";
                break;

            case ElectoralClass.State:
                titleContentDescription =
                    $"Current {StateCache.GetStateName(_StateCode)} Elected Representatives";
                break;

            case ElectoralClass.County:
                titleContentDescription = "Current County Representatives";
                metaContentLocation     =
                    $"{CountyCache.GetCountyName(_StateCode, _CountyCode)}, {StateCache.GetStateName(_StateCode)}";
                break;

            case ElectoralClass.Local:
                titleContentDescription = "Current Local District Representatives";
                metaContentLocation     =
                    $"{LocalDistricts.GetName(_StateCode, _LocalKey)}," +
                    $" {CountyCache.GetCountyName(_StateCode, _CountyCode)}, {StateCache.GetStateName(_StateCode)}";
                break;

            default:
                titleContentDescription = "Elected Representatives";
                break;
            }

            var metaContentDescription = titleContentDescription;

            if (metaContentLocation != Empty)
            {
                metaContentDescription += $", {metaContentLocation}";
            }

            //PageHeading.MainHeadingText = titleContentDescription;
            H1.InnerText    = titleContentDescription;
            Title           = Format(TitleTag, metaContentDescription, PublicMasterPage.SiteName);
            MetaDescription = Format(MetaDescriptionTag, metaContentDescription);
        }
Esempio n. 8
0
        private static void CheckForFatalCredentialingProblems(string usernameEntered)
        {
            switch (UserSecurityClass)
            {
            case MasterSecurityClass:
                // no additional info needed
                break;

            case StateAdminSecurityClass:
                if (!StateCache.IsValidStateCode(UserStateCode))
                {
                    HandleCredentialingInconsistency(usernameEntered, "Invalid StateCode");
                }
                break;

            case CountyAdminSecurityClass:
                if (!Counties.StateCodeCountyCodeExists(UserStateCode, UserCountyCode))
                {
                    HandleCredentialingInconsistency(usernameEntered, "Invalid CountyCode");
                }
                break;

            case LocalAdminSecurityClass:
                //if (!LocalDistricts.StateCodeCountyCodeLocalCodeExists(
                // UserStateCode, UserCountyCode, UserLocalCode))
                //  HandleCredentialingInconsistency(usernameEntered, "Invalid LocalCode");
                break;

            case PartySecurityClass:
                if (!Parties.PartyKeyExists(UserPartyKey))
                {
                    HandleCredentialingInconsistency(usernameEntered, "Invalid PartyKey");
                }
                break;

            case PoliticianSecurityClass:
                // no additional info needed --
                // they couldn't get this far without a valid politician key
                break;

            case DesignSecurityClass:
                if (!DomainDesigns.DomainDesignCodeExists(UserDesignCode))
                {
                    HandleCredentialingInconsistency(usernameEntered, "Invalid DesignCode");
                }
                break;

            case OrganizationSecurityClass:
                if (!Organizations.OrganizationCodeExists(UserOrganizationCode))
                {
                    HandleCredentialingInconsistency(
                        usernameEntered, "Invalid OrganizationCode");
                }
                break;
            }
        }
Esempio n. 9
0
        public void ApplyToResult(AddressFinderResult result)
        {
            result.Congress    = Congress;
            result.StateSenate = StateSenate;
            result.StateHouse  = StateHouse;
            result.County      = County;
            result.State       = StateCode;

            var votersUrl = MakeSetCookiesUrl(
                UrlManager.GetForVotersPageUri(StateCode), result.OriginalInput, result.Remember);

            result.RedirectUrl    = votersUrl;
            result.SuccessMessage = "Redirecting to the " + StateCache.GetStateName(StateCode) +
                                    " 'for Voters' page";

            //string electedOfficialsUrl = MakeSetCookiesUrl(
            //  UrlManager.GetElectedPageUri(
            //  StateCode, Congress, StateSenate, StateHouse, County));

            //ElectionsTable futureElectionsTable =
            //  Elections.GetFutureViewableDisplayDataByStateCode(StateCode);

            //if (futureElectionsTable.Count == 0)
            //{
            //  result.RedirectUrl = electedOfficialsUrl;
            //  result.SuccessMessage = "Redirecting to your elected officials page";
            //}
            //else
            //{
            //  //redirectUri = UrlManager.GetBallotPageUri(StateCode,
            //  //  Congress, StateSenate, StateHouse, County);
            //  HtmlGenericControl span = new HtmlSpan();
            //  span.Attributes["class"] = "selectOne";
            //  span.Controls.Add(new LiteralControl("Select "));
            //  HtmlAnchor a = new HtmlAnchor();
            //  span.Controls.Add(a);
            //  a.HRef = electedOfficialsUrl;
            //  a.InnerText = "Current elected officials";
            //  a.Title = a.InnerText;
            //  span.Controls.Add(new LiteralControl(" or sample ballot for:"));
            //  foreach (var row in futureElectionsTable)
            //  {
            //    span.Controls.Add(new LiteralControl("<br />"));
            //    a = new HtmlAnchor();
            //    span.Controls.Add(a);
            //    Uri uri = UrlManager.GetBallotPageUri(row.ElectionKey,
            //      Congress, StateSenate, StateHouse, County);
            //    a.HRef = MakeSetCookiesUrl(uri);
            //    a.InnerText = row.ElectionDesc;
            //    a.Title = a.InnerText;
            //  }
            //  result.SuccessMessage = db.RenderToString(span);
            //}
        }
Esempio n. 10
0
        public static Uri GetForVotersPageUri(string state)
        {
            if (!StateCache.IsValidStateCode(state))
            {
                return(GetSiteUri("forVoters.aspx"));
            }
            var qsc = new QueryStringCollection();

            AddNonEmptyParm(qsc, "State", state);
            return(GetStateUri(state, "forVoters.aspx", qsc));
        }
 private void FillInTitles()
 {
     ElectionTitle.InnerText = _ElectionDescription;
     if (StateCache.IsValidStateCode(_StateCode))
     {
         ElectionSubTitle.InnerText = Elections.GetElectoralClassDescription(_ElectionKey);
     }
     else
     {
         ElectionSubTitle.Visible = false;
     }
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            RegisterClientScript();

            if (Request.QueryString["iframe"] == "true")
            {
                form.AddCssClasses("iframe");
                this.IncludeJs("/js/jq/iframeResizer.contentWindow.min.js");
            }

            var     totalContests  = 0;
            var     ballotMeasures = 0;
            var     electionKey    = QueryElection;
            var     congress       = QueryCongress;
            var     stateSenate    = QueryStateSenate;
            var     stateHouse     = QueryStateHouse;
            var     countyCode     = QueryCounty;
            var     electionDesc   = Elections.GetElectionDesc(electionKey);
            Control report         = null;

            if (!string.IsNullOrWhiteSpace(electionKey) &&
                !string.IsNullOrWhiteSpace(congress) &&
                !string.IsNullOrWhiteSpace(stateSenate) &&
                !string.IsNullOrWhiteSpace(stateHouse) && !string.IsNullOrWhiteSpace(countyCode))
            {
                report = BallotReport2Tabbed.GetReport(electionKey, congress, stateSenate,
                                                       stateHouse, countyCode, out totalContests, out ballotMeasures);
            }

            if (totalContests != 0 || ballotMeasures != 0)
            {
                H1.InnerText = electionDesc;
                report.AddTo(ReportPlaceHolder);
                FillInDropdowns(electionKey, countyCode, congress, stateSenate, stateHouse);
            }
            else
            {
                StateCache.Populate(StateList, "<find address or select state>", string.Empty);
                var defaultList = new List <SimpleListItem>
                {
                    new SimpleListItem
                    {
                        Text  = "<find address or select state>",
                        Value = string.Empty
                    }
                };
                Utility.PopulateFromList(CountyList, defaultList);
                Utility.PopulateFromList(CongressList, defaultList);
                Utility.PopulateFromList(StateSenateList, defaultList);
                Utility.PopulateFromList(StateHouseList, defaultList);
                Utility.PopulateFromList(ElectionList, defaultList);
            }
        }
Esempio n. 13
0
        public static string FindStateCode()
        {
            // reworked to eliminate ViewState references
            var stateCode = QueryState;

            if (IsNullOrWhiteSpace(stateCode))
            {
                if (IsPublicPage)
                {
                    stateCode = UrlManager.CurrentDomainDataCode;
                }
                else if (IsMasterUser || IsAdminUser)
                {
                    stateCode = UserStateCode;
                    if (IsNullOrWhiteSpace(stateCode))
                    {
                        stateCode = Elections.GetStateCodeFromKey(QueryElection);
                    }
                    if (IsNullOrWhiteSpace(stateCode))
                    {
                        stateCode = Offices.GetStateCodeFromKey(QueryOffice);
                    }
                    if (IsNullOrWhiteSpace(stateCode))
                    {
                        stateCode = Politicians.GetStateCodeFromKey(QueryId);
                    }
                    if (IsNullOrWhiteSpace(stateCode))
                    {
                        stateCode = Issues.GetStateCodeFromKey(QueryIssue);
                    }
                    if (IsNullOrWhiteSpace(stateCode))
                    {
                        stateCode = Referendums.GetStateCodeFromKey(QueryReferendum);
                    }
                }
                else if (IsPoliticianUser)
                {
                    stateCode = Politicians.GetStateCodeFromKey(UserPoliticianKey);
                }
                else if (IsPartyUser)
                {
                    stateCode = Parties.GetStateCodeFromKey(UserPartyKey);
                }
            }

            return(!IsNullOrWhiteSpace(stateCode) &&
                   (StateCache.IsValidStateOrFederalCode(stateCode) ||
                    GetPage <SecureAdminPage>()?.NonStateCodesAllowed.Contains(stateCode) == true)
        ? stateCode
        : Empty);
        }
Esempio n. 14
0
        private void HandlePoliticianIssuePage()
        {
            var stateCode = Politicians.GetStateCodeFromKey(GetQueryParm("Id"));

            if (StateCache.IsValidStateCode(stateCode))
            {
                NormalizedUri = UrlManager.GetPoliticianIssuePageUri(stateCode,
                                                                     GetQueryParm("Id"), GetQueryParm("Issue"));
            }
            else
            {
                ErrorMessage = "Invalid StateCode";
            }
        }
Esempio n. 15
0
        private static Dictionary <string, LdsInfo> GetLdsInfoDictionary(string zip5,
                                                                         IEnumerable <string> zip4List)
        {
            var ldsDictionary = new Dictionary <string, LdsInfo>();
            var table         = Uszd.GetDataByZip4List(zip5, zip4List, 0);

            foreach (var row in table)
            {
                var stateCode = StateCache.StateCodeFromLdsStateCode(row.LdsStateCode);
                ldsDictionary[row.Zip4] = new LdsInfo(stateCode, row.Congress,
                                                      row.StateSenate, row.StateHouse, row.County);
            }
            return(ldsDictionary);
        }
Esempio n. 16
0
        private void HandleElectedPage()
        {
            var stateCode = UrlManager.FindStateCode();

            if (StateCache.IsValidStateCode(stateCode))
            {
                NormalizedUri = UrlManager.GetElectedPageUri(stateCode,
                                                             GetQueryParm("Congress"), GetQueryParm("StateSenate"),
                                                             GetQueryParm("StateHouse"), GetQueryParm("County"));
            }
            else
            {
                ErrorMessage = "Invalid_StateCode";
            }
        }
Esempio n. 17
0
        public bool DoOneZipCode(string zipCode)
        {
            // Get all zip rows from ZipStreetsDownloaded
            var    isSingle           = false;
            var    found              = false;
            string singleLdsStateCode = null;
            var    streetsTable       = ZipStreetsDownloaded.GetLookupDataByZipCode(zipCode, 0);

            if (streetsTable.Count > 0)
            {
                found = true;

                // Fetch and summarize the USZD data
                var ldsDictionary = new Dictionary <LdsInfo, object>();
                var zip4S         = CreateZipPlus4List(streetsTable);
                var uszdTable     = Uszd.GetDataByZip4List(zipCode, zip4S, 0);
                foreach (var row in uszdTable)
                {
                    var stateCode = StateCache.StateCodeFromLdsStateCode(row.LdsStateCode);
                    singleLdsStateCode = row.LdsStateCode;
                    var ldsInfo = new LdsInfo(stateCode, row.Congress, row.StateSenate,
                                              row.StateHouse, row.County);
                    ldsDictionary[ldsInfo] = null;
                }
                if (ldsDictionary.Count == 1)
                {
                    isSingle = true;
                    var singleLdsInfo = ldsDictionary.Keys.Single();
                    if (!_SuppressUpdate)
                    {
                        ZipSingleUszd.Insert(zipCode: zipCode,
                                             congress: singleLdsInfo.Congress.Substring(1),
                                             // LdsInfo padds it to 3
                                             stateSenate: singleLdsInfo.StateSenate,
                                             stateHouse: singleLdsInfo.StateHouse,
                                             ldsStateCode: singleLdsStateCode, county: singleLdsInfo.County,
                                             stateCode: singleLdsInfo.StateCode);
                    }
                }
            }

            if (found)
            {
                Report("{0}: {1}", zipCode, isSingle ? "Single" : "Multiple");
            }

            return(isSingle);
        }
Esempio n. 18
0
        public static string FormatLegislativeDistrictsFromQueryStringForHeading(bool useSpans = false)
        {
            string subtitle;

            if (StateCache.IsValidStateCode(QueryState))
            {
                subtitle = (useSpans
            ? "<span class=\"districts-head\">For address in:</span>"
            : "<span class=\"districtsHead\">For address in:</span><br />") +
                           FormatLegislativeDistrictsFromQueryString(useSpans ? null : "<br /");
            }
            else
            {
                subtitle = "for any address in the United States";
            }
            return(subtitle);
        }
Esempio n. 19
0
 protected override void OnPreLoad(EventArgs e)
 {
     base.OnPreLoad(e);
     PartyKey       = ViewStatePartyKey;
     PartyKeyExists = Parties.PartyKeyExists(PartyKey);
     if (PartyKeyExists)
     {
         PartyName           = PageCache.Parties.GetPartyName(PartyKey);
         PartyCode           = PageCache.Parties.GetPartyCode(PartyKey);
         StateCode           = PageCache.Parties.GetStateCode(PartyKey);
         IsPartyMajor        = PageCache.Parties.GetIsPartyMajor(PartyKey);
         StateCodeIsNonState = !StateCache.IsValidStateCode(StateCode);
     }
     else if (!IsSignedIn) // if not signed in, dump to sign in pageName
     {
         RedirectToSignInPage();
     }
 }
Esempio n. 20
0
        public static void AddStateLinksToDiv(HtmlGenericControl div, string stateCode,
                                              bool includeCurrentOfficials, bool includeFutureElections)
        {
            if (includeCurrentOfficials)
            {
                var linkInfo = new LinkInfo
                {
                    Description =
                        StateCache.GetStateName(stateCode) + " Current Elected Officials",
                    HRef = UrlManager.GetOfficialsPageUri(stateCode)
                };
                AddLinksToLinkBox(div, new List <LinkInfo> {
                    linkInfo
                });
            }

            AddLinksToLinkBox(div, GetStateLinks(stateCode, includeFutureElections));
        }
Esempio n. 21
0
        private static List <LinkInfo> GetUpcomingLinks(string stateCode)
        {
            var linkList = new List <LinkInfo>();

            if (StateCache.IsValidStateCode(stateCode))
            {
                var table = Elections.GetFutureViewableDisplayDataByStateCode(stateCode);
                linkList.AddRange(
                    table.Select(
                        row =>
                        new LinkInfo(row)
                {
                    HRef = UrlManager.GetElectionPageUri(row.ElectionKey)
                }));
            }

            return(linkList);
        }
Esempio n. 22
0
        private static void AddUpcomingLinksToDiv(Control div,
                                                  string stateCode)
        {
            var links = GetUpcomingLinks(stateCode);

            if (links.Count > 0)
            {
                ForResearchPage.AddLinksToLinkBox(div, links);
            }
            else
            {
                var p       = new HtmlP().AddTo(div);
                var message =
                    $"No {StateCache.GetStateName(stateCode)} upcoming election reports are available. " +
                    "Please check back later.";
                new LiteralControl(message).AddTo(p);
            }
        }
Esempio n. 23
0
        private void HandleIssue2Page()
        {
            var electionKey = MemCache.IsValidElection(GetQueryParm("Election"))
        ? GetQueryParm("Election")
        : FixElectionKeyFromQueryString();

            var stateCode = Elections.GetStateCodeFromKey(electionKey);

            if (StateCache.IsValidStateCode(stateCode) && !string.IsNullOrEmpty(electionKey))
            {
                NormalizedUri = UrlManager.GetIssue2PageUri(stateCode, electionKey,
                                                            GetQueryParm("Congress"), GetQueryParm("StateSenate"),
                                                            GetQueryParm("StateHouse"), GetQueryParm("County"), GetQueryParm("Office"));
            }
            else
            {
                ErrorMessage =
                    "Invalid_ElectionKey|State|Congress|StateSenate|StateHouse|County";
            }
        }
Esempio n. 24
0
 public static Uri GetOfficialsPageUri(string report, string county = null, string local = null)
 {
     if (report != null && StateCache.IsValidStateCode(report))
     {
         var qsc = new QueryStringCollection();
         AddNonEmptyParm(qsc, "State", report);
         AddNonEmptyParm(qsc, "Report", report);
         AddNonEmptyParm(qsc, "County", county);
         AddNonEmptyParm(qsc, "Local", local);
         return(GetStateUri(report, "Officials.aspx", qsc));
     }
     else
     {
         var qsc = new QueryStringCollection();
         AddNonEmptyParm(qsc, "Report", report);
         return(HttpContext.Current == null
   ? GetSiteUri("Officials.aspx", qsc)
   : GetStateUri(G.State_Code(), "Officials.aspx", qsc));
     }
 }
Esempio n. 25
0
        public static ElectoralClass Electoral_Class(string stateCode, string countyCode,
                                                     string localCode)
        {
            if ((!string.IsNullOrEmpty(localCode)) && (!string.IsNullOrEmpty(countyCode)) &&
                (!string.IsNullOrEmpty(stateCode)))
            {
                return(ElectoralClass.Local);
            }

            if ((!string.IsNullOrEmpty(countyCode)) && (!string.IsNullOrEmpty(stateCode)))
            {
                return(ElectoralClass.County);
            }

            if (!string.IsNullOrEmpty(stateCode))
            {
                switch (stateCode)
                {
                case "PP":
                case "US":
                case "U1":
                    return(ElectoralClass.USPresident);

                case "U2":
                    return(ElectoralClass.USSenate);

                case "U3":
                    return(ElectoralClass.USHouse);

                case "U4":
                    return(ElectoralClass.USGovernors);

                default:
                    return(StateCache.IsValidStateCode(stateCode)
              ? ElectoralClass.State
              : ElectoralClass.All);
                }
            }

            return(ElectoralClass.Unknown);
        }
Esempio n. 26
0
        public static string State_Code()
        {
            //**Test
            var stateCode = SecurePage.GetViewStateStateCode();

            if (stateCode != null)
            {
                return(stateCode);
            }

            if (VotePage.IsPublicPage)
            {
                return(StateCode_Domain_This());
            }

            if (SecurePage.IsMasterUser)
            {
                if (!string.IsNullOrEmpty(VotePage.QueryState))
                {
                    Session_Put("UserCountyCode", string.Empty);
                    Session_Put("UserLocalCode", string.Empty);
                    Session_Put("UserStateCode", VotePage.QueryState);

                    return(VotePage.QueryState);
                }
                return(!string.IsNullOrEmpty(User_StateCode())
          ? User_StateCode()
          : string.Empty);
            }
            if (!SecurePage.IsStateAdminUser)
            {
                return(string.Empty);
            }
            if (StateCache.IsValidStateOrFederalCode(User_StateCode(), false))
            {
                return(User_StateCode());
            }
            return(StateCache.IsValidStateOrFederalCode(Domain_StateCode_This(), false)
        ? Domain_StateCode_This()
        : string.Empty);
        }
Esempio n. 27
0
        public static string FindStateCode()
        {
            // This is a replacement for db.State_Code() because in this context
            // we are only dealing with public pages. It is a rework of db.Domain_DataCode_This()
            var stateCode = HttpContext.Current.Request.QueryString["State"];

            if (string.IsNullOrEmpty(stateCode))
            {
                stateCode = HttpContext.Current.Request.QueryString["Data"];
            }
            if (string.IsNullOrEmpty(stateCode))
            {
                stateCode = GetStateCodeFromHostName(GetCurrentHostName());
            }
            stateCode = stateCode.ToUpper();
            if (!StateCache.IsValidStateCode(stateCode))
            {
                stateCode = string.Empty;
            }
            return(stateCode);
        }
Esempio n. 28
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                var stateName = PublicMasterPage.StateName + " ";
                if (stateName == "US ")
                {
                    stateName = Empty;
                }
                Title           = Format(TitleTag, PublicMasterPage.SiteName);
                MetaDescription = Format(MetaDescriptionTag, stateName);
            }

            string selectedState = null;
            string firstEntry    = null;

            if (DomainData.IsValidStateCode) // Single state
            {
                selectedState = DomainData.FromQueryStringOrDomain;
                AddStateLinksToDiv(StateLinkEntries, selectedState, true, true);
                StateName.InnerText = StateCache.GetStateName(selectedState);
            }
            else
            {
                firstEntry = "<select state>";
                new HtmlP {
                    InnerText = "No state selected"
                }.AddTo(StateLinkEntries);
                StateName.InnerText = "<no state selected>";
            }

            StateCache.Populate(StateElectionDropDown, firstEntry, "XX", selectedState);

            GetLinkBox(PresidentLinks, "US President and Vice-President",
                       GetPresidentLinks());
            GetLinkBox(SenateLinks, "US Senate", GetSenateLinks());
            GetLinkBox(HouseLinks, "US House of Representatives", GetHouseLinks());
            GetLinkBox(GovernorLinks, "State Governors and Lieutenant Governors",
                       GetGovernorLinks());
        }
Esempio n. 29
0
        public static string FormatLegislativeDistrictsFromQueryString(
            string separator = "<br />")
        {
            var lines = new List <string>();

            if (QueryState != "DC")
            {
                if (QueryCongress != "000")
                {
                    lines.Add("US House District " + QueryCongress.TrimStart('0') + " " +
                              StateCache.GetStateName(QueryState));
                }
                if (QueryStateSenate != "000")
                {
                    lines.Add(StateCache.GetStateName(QueryState) + " Senate District " +
                              QueryStateSenate.TrimStart('0'));
                }
                if (QueryStateHouse != "000")
                {
                    lines.Add(StateCache.GetStateName(QueryState) + " House District " +
                              QueryStateHouse.TrimStart('0'));
                }
                if (QueryCounty != string.Empty)
                {
                    lines.Add(CountyCache.GetCountyName(QueryState, QueryCounty));
                }
            }
            else if (QueryStateSenate != "000")
            {
                lines.Add("Ward " + QueryStateSenate.TrimStart('0'));
            }

            if (separator == null)
            {
                return("<span>" + string.Join("</span><span>", lines) + "</span>");
            }
            return(string.Join(separator, lines));
        }
Esempio n. 30
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Report.SignedInReportUser != ReportUser.Public)
            {
                this.IncludeCss("~/css/MainCommon.css");
                this.IncludeCss("~/css/SecondaryCommon.css");
                this.IncludeCss("~/css/All.css");
                this.IncludeCss("~/css/Officials.css");
            }

            if (HasUrlError)
            {
                InnerContent.Controls.Clear();
                var p = new HtmlP().AddTo(InnerContent, "not-found-error");
                new LiteralControl($"We could not show the information you requested: {UrlError}").AddTo(p);
                return;
            }

            _StateCode  = QueryReport;
            _CountyCode = Empty;
            _LocalKey   = Empty;
            if (IsNullOrWhiteSpace(_StateCode))
            {
                _StateCode = QueryState;
            }
            if (StateCache.IsValidStateCode(_StateCode))
            {
                _CountyCode = QueryCounty;
                _LocalKey   = QueryLocal;
            }

            _ElectoralClass = Offices.GetElectoralClass(_StateCode, _CountyCode, _LocalKey);

            AnalyzeElectoralClass();
            var report = OfficialsReportResponsive.GetReport(_StateCode, _CountyCode, _LocalKey);

            report.AddTo(ReportPlaceHolder);
        }