Пример #1
0
 private static bool IsValidElectionKey(string electionKey)
 {
     if (MemCache.IsValidElection(electionKey))
     {
         if (Electoral_Class_Election(electionKey) == ElectoralClass.State ||
             Electoral_Class_Election(electionKey) == ElectoralClass.County ||
             Electoral_Class_Election(electionKey) == ElectoralClass.Local)
         {
             return(true);
         }
         else if (Electoral_Class_Election(electionKey) == ElectoralClass.County &&
                  Elections.GetCountyCodeFromKey(electionKey) == "000")
         {
             //Report of County Links to County Elections
             return(true);
         }
         else if (Electoral_Class_Election(electionKey) == ElectoralClass.Local &&
                  Elections.GetLocalCodeFromKey(electionKey) == "00")
         {
             //Report of Local Links to Local Elections
             return(true);
         }
         else
         {
             return(false);
         }
     }
     return(false);
 }
Пример #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";
            }
        }
Пример #3
0
        private void HandleCompareCandidatesPage()
        {
            var officeKey = string.Empty;

            var electionKey = MemCache.IsValidElection(GetQueryParm("Election"))
        ? GetQueryParm("Election")
        : FixElectionKeyFromQueryString();

            if (!string.IsNullOrEmpty(electionKey))
            {
                if (Offices.IsInElection(GetQueryParm("Office"), electionKey))
                {
                    officeKey = GetQueryParm("Office");
                }
            }

            var stateCode = Elections.GetStateCodeFromKey(electionKey);

            if (!string.IsNullOrEmpty(electionKey) && !string.IsNullOrEmpty(officeKey))
            {
                NormalizedUri = UrlManager.GetCompareCandidatesPageUri(stateCode, electionKey,
                                                                       officeKey);
            }
            else
            {
                ErrorMessage =
                    "Cannot find this combination of State, Election and Office";
            }
        }
Пример #4
0
        private void HandleIssuePage()
        {
            var officeKey = string.Empty;
            var issueKey  = string.Empty;

            var electionKey = MemCache.IsValidElection(GetQueryParm("Election"))
        ? GetQueryParm("Election")
        : FixElectionKeyFromQueryString();

            if (!string.IsNullOrEmpty(electionKey))
            {
                if (Offices.IsInElection(GetQueryParm("Office"), electionKey))
                {
                    officeKey = GetQueryParm("Office");
                }

                if (!string.IsNullOrEmpty(officeKey))
                {
                    if (IsValidIssue(GetQueryParm("Issue"),
                                     Elections.GetStateCodeFromKey(electionKey)))
                    {
                        issueKey = GetQueryParm("Issue");
                    }
                }
            }

            var stateCode = Elections.GetStateCodeFromKey(electionKey);

            if (!string.IsNullOrEmpty(electionKey) && !string.IsNullOrEmpty(officeKey) &&
                !string.IsNullOrEmpty(issueKey))
            {
                if (OriginalUri.AbsolutePath.ToLower() == "/issue2.aspx")
                {
                    NormalizedUri = UrlManager.GetIssue2PageUri(stateCode, electionKey,
                                                                officeKey, issueKey);
                }
                else
                {
                    NormalizedUri = UrlManager.GetIssuePageUri(stateCode, electionKey,
                                                               officeKey, issueKey);
                }
            }
            else
            {
                ErrorMessage =
                    "Cannot find this combination of State, Election, Office and Issue";
            }
        }
Пример #5
0
        private void HandleReferendumPage()
        {
            var electionKey = MemCache.IsValidElection(GetQueryParm("Election"))
        ? GetQueryParm("Election")
        : FixElectionKeyFromQueryString();
            var stateCode     = Elections.GetStateCodeFromKey(electionKey);
            var referendumKey = GetQueryParm("Referendum");

            if (!string.IsNullOrEmpty(electionKey) && !string.IsNullOrEmpty(stateCode))
            {
                NormalizedUri = UrlManager.GetReferendumPageUri(stateCode, electionKey,
                                                                referendumKey);
            }
            else
            {
                ErrorMessage = "Invalid_ElectionKey|ReferendumKey|StateCode";
            }
        }
Пример #6
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";
            }
        }