Beispiel #1
0
        /// <summary>
        /// Converts the <see cref="ActiveCandidateTds.ActiveCandidateRow"/> representation of an active candidate into its <see cref="ActiveCandidate"/> object equivalent.
        /// </summary>
        /// <param name="row">A <see cref="ActiveCandidateTds.ActiveCandidateRow"/> containing the active candidate to convert.</param>
        /// <returns>An <see cref="ActiveCandidate"/> equivalent to the active candidate represented by <paramref name="row"/>.</returns>
        /// <exception cref="ArgumentNullException"><paramref name="row"/> is a null reference.</exception>
        private static ActiveCandidate Parse(ActiveCandidateTds.ActiveCandidateRow row)
        {
            if (row == null)
            {
                throw new ArgumentNullException("row", "Row must be valid and cannot be null.");
            }
            char committeeID;

            return(new ActiveCandidate(row.CandidateID.Trim(), row.ElectionCycle.Trim())
            {
                // basic information
                LastUpdated = row.LastUpdated,
                Honorific = CPConvert.ToHonorific(row.HonorificCode.Trim()),
                LastName = row.LastName.Trim(),
                FirstName = row.FirstName.Trim(),
                MiddleInitial = string.IsNullOrWhiteSpace(row.MiddleInitial) ? null : row.MiddleInitial.Trim().ToCharArray()[0] as char?,
                Address = new PostalAddress()
                {
                    StreetNumber = row.StreetNumber.Trim(),
                    StreetName = row.StreetName.Trim(),
                    Apartment = row.Apartment.Trim(),
                    City = row.City.Trim(),
                    State = row.State.Trim(),
                    Zip = new ZipCode(row.Zip.Trim())
                },
                DaytimePhone = new PhoneNumber(row.DaytimePhone.Trim())
                {
                    Extension = row.DaytimePhoneExt.Trim()
                },
                EveningPhone = new PhoneNumber(row.EveningPhone.Trim())
                {
                    Extension = row.EveningPhoneExt.Trim()
                },
                Fax = new PhoneNumber(row.Fax.Trim()),
                Email = row.Email.Trim(),

                // employer information
                Employer = new Entity()
                {
                    Type = EntityType.Employer,
                    LastName = row.EmployerName.Trim(),
                    Address = new PostalAddress()
                    {
                        StreetNumber = row.EmployerStreetNumber.Trim(),
                        StreetName = row.EmployerStreetName.Trim(),
                        City = row.EmployerCity.Trim(),
                        State = row.EmployerState.Trim(),
                        Zip = new ZipCode(row.EmployerZip.Trim())
                    },
                    DaytimePhone = new PhoneNumber(row.EmployerPhone.Trim())
                    {
                        Extension = row.EmployerPhoneExt.Trim()
                    },
                    Fax = new PhoneNumber(row.EmployerFax.Trim())
                },

                // activation information
                Office = new NycPublicOffice(CPConvert.ToNycPublicOfficeType(row.OfficeCode.Trim()))
                {
                    Borough = CPConvert.ToNycBorough(row.BoroughCode.Trim()),
                    District = string.IsNullOrEmpty(row.DistrictCode.Trim()) ? byte.MinValue : Convert.ToByte(row.DistrictCode.Trim())
                },
                CertificationDate = row.IsCertificationDateNull() ? null : row.CertificationDate as DateTime?,
                FilerRegistrationDate = row.IsFilerRegistrationDateNull() ? null : row.FilerRegistrationDate as DateTime?,
                TerminationDate = row.IsTerminationDateNull() ? null : row.TerminationDate as DateTime?,
                TerminationReason = CPConvert.ToTerminationReason(row.TerminationReasonCode),
                Classification = CPConvert.ToCfbClassification(row.ClassificationCode.Trim()),
                PoliticalParty = (row.IsPoliticalPartyNull()) ? string.Empty : row.PoliticalParty.Trim(),
                IsDirectDepositAuthorized = "Y".Equals(row.HasDirectDeposit, StringComparison.InvariantCultureIgnoreCase),
                IsRRDirectDepositAuthorized = "Y".Equals(row.HasRRDirectDeposit, StringComparison.InvariantCultureIgnoreCase),
                AuditorName = row.IsAuditorNameNull() ? null : row.AuditorName.Trim(),
                CsuLiaisonName = row.IsCsuLiaisonNameNull() ? null : row.CsuLiaisonName.Trim(),

                // principal committee info
                PrincipalCommittee = row.IsPrincipalCommitteeNull() ? null : row.PrincipalCommittee.Trim(),
                PrincipalCommitteeID = !row.IsPrincipalCommitteeIDNull() && char.TryParse(row.PrincipalCommitteeID.Trim(), out committeeID) ? committeeID as char? : null
            });
        }
Beispiel #2
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);
            }
        }