示例#1
0
        /// <summary>
        /// Converts the <see cref="CandidateTds.CandidateRow"/> representation of a candidate into its <see cref="Candidate"/> object equivalent.
        /// </summary>
        /// <param name="row">A <see cref="CandidateTds.CandidateRow"/> containing the candidate to convert.</param>
        /// <returns>A <see cref="Candidate"/> equivalent to the candidate represented by <paramref name="row"/>.</returns>
        /// <exception cref="ArgumentNullException"><paramref name="row"/> is a null reference.</exception>
        private Candidate Parse(CandidateTds.CandidateRow row)
        {
            if (row == null)
            {
                throw new ArgumentNullException("row", "Row must be valid and cannot be null.");
            }
            return(new Candidate(row.CandidateID.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())
                }
            });
        }
示例#2
0
 /// <summary>
 /// Retrieves all campaign liaisons on record for the specified candidate and committee.
 /// </summary>
 /// <param name="candidateID">The ID of the candidate whose liaisons are to be retrieved.</param>
 /// <param name="committeeID">The ID of the committee whose liaisons are to be retrieved.</param>
 /// <returns>A collection of all campaign liaisons on record for the specified candidate and committee, indexed by liaison ID.</returns>
 public Dictionary <byte, Liaison> GetLiaisons(string candidateID, char committeeID)
 {
     using (AuthorizedCommitteeTds ds = new AuthorizedCommitteeTds())
     {
         using (CampaignLiaisonsTableAdapter ta = new CampaignLiaisonsTableAdapter())
         {
             ta.Fill(ds.CampaignLiaisons, candidateID, committeeID.ToString());
         }
         Dictionary <byte, Liaison> d = new Dictionary <byte, Liaison>(ds.CampaignLiaisons.Count);
         foreach (AuthorizedCommitteeTds.CampaignLiaisonsRow row in ds.CampaignLiaisons.Rows)
         {
             byte id;
             if (byte.TryParse(row.LiaisonID, out id))
             {
                 d.Add(id, new Liaison(id)
                 {
                     Type          = CPConvert.ToLiaisonType(row.LiaisonTypeCode.Trim()) == LiaisonType.Consultant ? EntityType.Consultant : EntityType.Liaison,
                     LiaisonType   = CPConvert.ToLiaisonType(row.LiaisonTypeCode.Trim()),
                     ContactOrder  = CPConvert.ToContactOrder(row.ContactOrderCode),
                     Honorific     = CPConvert.ToHonorific(row.HonorificCode.Trim()),
                     LastName      = row.LastName.Trim(),
                     FirstName     = row.FirstName.Trim(),
                     MiddleInitial = string.IsNullOrWhiteSpace(row.MI) ? null : row.MI.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(),
                     EntityName           = row.EntityName.Trim(),
                     HasManagerialControl = "Y".Equals(row.HasManagerialControl.Trim(), System.StringComparison.OrdinalIgnoreCase),
                     IsVGLiaison          = "Y".Equals(row.IsVGLiaison.Trim(), System.StringComparison.OrdinalIgnoreCase)
                 });
             }
         }
         return(d);
     }
 }
示例#3
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
            });
        }
示例#4
0
        /// <summary>
        /// Retrieves all authorized committees for a candidate in a specific election cycle.
        /// </summary>
        /// <param name="candidateID">The ID of the candidate whose authorized committees are to be retrieved.</param>
        /// <param name="electionCycle">The election cycle in which to search.</param>
        /// <returns>A collection of all authorized committees on record for the specified candidate and election cycle.</returns>
        public AuthorizedCommittees GetAuthorizedCommittees(string candidateID, string electionCycle)
        {
            using (AuthorizedCommitteeTds ds = new AuthorizedCommitteeTds())
            {
                using (AuthorizedCommitteesTableAdapter ta = new AuthorizedCommitteesTableAdapter())
                {
                    ta.Fill(ds.AuthorizedCommittees, candidateID, electionCycle);
                }
                AuthorizedCommittees c = new AuthorizedCommittees(ds.AuthorizedCommittees.Count);
                foreach (AuthorizedCommitteeTds.AuthorizedCommitteesRow row in ds.AuthorizedCommittees.Rows)
                {
                    if (string.IsNullOrWhiteSpace(row.CommitteeID))
                    {
                        continue;
                    }

                    // basic committee info
                    AuthorizedCommittee ac = new AuthorizedCommittee(row.CommitteeID.ToCharArray()[0])
                    {
                        // authorized committee info
                        NotarizationDate = row.IsSwornDateNull() ? null : row.SwornDate as DateTime?,
                        IsActive         = "Y".Equals(row.IsActive.Trim(), StringComparison.CurrentCultureIgnoreCase),
                        IsPrincipal      = "Y".Equals(row.IsPrincipal.Trim(), StringComparison.CurrentCultureIgnoreCase),
                        ContactOrder     = CPConvert.ToContactOrder(row.TreasurerContactOrder),
                        LastUpdated      = row.LastUpdated,

                        // treasurer info
                        Treasurer = new Entity()
                        {
                            Type          = EntityType.Treasurer,
                            Honorific     = CPConvert.ToHonorific(row.TreasurerHonorificCode.Trim()),
                            LastName      = row.TreasurerLastName.Trim(),
                            FirstName     = row.TreasurerFirstName.Trim(),
                            MiddleInitial = string.IsNullOrWhiteSpace(row.TreasurerMI) ? null : row.TreasurerMI.Trim().ToCharArray()[0] as char?,
                            Address       = new PostalAddress()
                            {
                                StreetNumber = row.TreasurerStreetNumber.Trim(),
                                StreetName   = row.TreasurerStreetName.Trim(),
                                Apartment    = row.TreasurerApartment.Trim(),
                                City         = row.TreasurerCity.Trim(),
                                State        = row.TreasurerState.Trim(),
                                Zip          = new ZipCode(row.TreasurerZip.Trim())
                            },
                            DaytimePhone = new PhoneNumber(row.TreasurerDaytimePhone.Trim())
                            {
                                Extension = row.TreasurerDaytimePhoneExt.Trim()
                            },
                            EveningPhone = new PhoneNumber(row.TreasurerEveningPhone.Trim())
                            {
                                Extension = row.TreasurerEveningPhoneExt.Trim()
                            },
                            Fax          = new PhoneNumber(row.TreasurerFax.Trim()),
                            Email        = row.TreasurerEmail.Trim(),
                            ContactOrder = CPConvert.ToContactOrder(row.TreasurerContactOrder),
                            // treasurer employer
                            Employer = new Entity()
                            {
                                Type     = EntityType.Employer,
                                LastName = row.TreasurerEmployerName.Trim(),
                                Address  = new PostalAddress()
                                {
                                    StreetNumber = row.TreasurerEmployerStreetNumber.Trim(),
                                    StreetName   = row.TreasurerEmployerStreetName.Trim(),
                                    City         = row.TreasurerEmployerCity.Trim(),
                                    State        = row.TreasurerEmployerState.Trim(),
                                    Zip          = new ZipCode(row.TreasurerEmployerZip.Trim())
                                },
                                DaytimePhone = new PhoneNumber(row.TreasurerEmployerPhone.Trim())
                                {
                                    Extension = row.TreasurerEmployerPhoneExt.Trim()
                                },
                                Fax = new PhoneNumber(row.TreasurerEmployerFax.Trim()),
                            }
                        },

                        // last election info
                        LastElectionDate     = row.IsLastElectionDateNull() ? null : row.LastElectionDate as DateTime?,
                        LastElectionOffice   = row.LastElectionOffice.Trim(),
                        LastElectionDistrict = row.LastElectionDistrict.Trim(),
                        LastPrimaryParty     = row.IsLastPrimaryPartyNull() ? null : row.LastPrimaryParty.Trim()
                    }.LoadCommitteeData(row);

                    // liaisons
                    ac.Liaisons = this.GetLiaisons(candidateID, ac.ID);

                    // bank accounts
                    ac.BankAccounts = this.GetBankAccounts(candidateID, electionCycle, ac.ID);

                    c.Committees.Add(ac.ID, ac);
                }
                return(c);
            }
        }