예제 #1
0
        /// <summary>
        /// Retrieves a collection of the specified candidate's complete threshold status history for the specified election cycle.
        /// </summary>
        /// <param name="candidateID">The ID of the candidate whose Conflict of Interest Board receipts are to be retrieved.</param>
        /// <param name="electionCycle">The election cycle in which to search.</param>
        /// <returns>A collection of the specified candidate's complete threshold status history for the specified election cycle.</returns>
        public ThresholdHistory GetThresholdHistory(string candidateID, string electionCycle)
        {
            Election election = GetElections(CPProviders.SettingsProvider.MinimumElectionCycle)[electionCycle];

            if (election == null || string.IsNullOrEmpty(candidateID))
            {
                return(null);
            }
            using (ThresholdTds ds = new ThresholdTds())
            {
                using (ThresholdTableAdapter ta = new ThresholdTableAdapter())
                {
                    ta.Fill(ds.Threshold, candidateID, election.Cycle);
                }
                var statements           = this.GetStatements(election.Cycle);
                ThresholdHistory history = new ThresholdHistory();
                ThresholdStatus  status;
                foreach (ThresholdTds.ThresholdRow row in ds.Threshold.Rows)
                {
                    try
                    {
                        Statement statement;
                        if (!statements.TryGetValue((byte)row.Statement, out statement))
                        {
                            continue;
                        }
                        // if a new statement is being added, create a new status statement group
                        if (!history.History.TryGetValue(statement.Number, out status))
                        {
                            status = new ThresholdStatus(statement.Number);
                            history.History.Add(statement.Number, status);
                        }
                        NycBorough borough = CPConvert.ToNycBorough(row.BoroughCode.Trim());
                        status.Add(new ThresholdRevision(statement, CPConvert.ToThresholdRevisionType(row.Type.Trim()))
                        {
                            Date           = row.Date,
                            Number         = (ushort)row.Number,
                            NumberRequired = (ushort)row.NumberRequired,
                            Funds          = row.Funds,
                            FundsRequired  = row.FundsRequired,
                            Office         = (borough != NycBorough.Unknown) ? new NycPublicOffice(borough) : new NycPublicOffice(CPConvert.ToNycPublicOfficeType(row.OfficeCode.Trim()))
                        });
                    }
                    catch (InvalidCastException)
                    {
                    }
                }
                return(history);
            }
        }
예제 #2
0
        /// <summary>
        /// Converts the value of the specified <see cref="NycBorough"/> to its equivalent <see cref="String"/> representation.
        /// </summary>
        /// <param name="borough">A New York City borough.</param>
        /// <returns>The <see cref="String"/> equivalent of the value of <paramref name="borough"/>.</returns>
        public static string ToString(NycBorough borough)
        {
            switch (borough)
            {
            case NycBorough.Bronx: return("Bronx");

            case NycBorough.Brooklyn: return("Brooklyn");

            case NycBorough.Manhattan: return("Manhattan");

            case NycBorough.Queens: return("Queens");

            case NycBorough.StatenIsland: return("Staten Island");

            case NycBorough.OutOfCity: return("Out of City");

            default: return(string.Empty);
            }
        }
예제 #3
0
 /// <summary>
 /// Gets the borough presided over if this office is Borough President. A return value indicates whether the fetch succeeded.
 /// </summary>
 /// <param name="borough">When this method returns, contains the borough presided over, if this office is Borough President; otherwise, unknown. This parameter is passed uninitialized.</param>
 /// <returns>true if this office is Borough President and the fetch succeeded; otherwise, false.</returns>
 public bool TryGetBorough(out NycBorough borough)
 {
     borough = this._borough;
     return(this._borough != NycBorough.Unknown);
 }
예제 #4
0
 /// <summary>
 /// Declares a Borough President of New York City.
 /// </summary>
 /// <param name="borough">The borough presided over.</param>
 public NycPublicOffice(NycBorough borough)
 {
     _type    = NycPublicOfficeType.BoroughPresident;
     _borough = borough;
 }