예제 #1
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);
     }
 }
예제 #2
0
 /// <summary>
 /// Retrieves committees for a candidate.
 /// </summary>
 /// <param name="candidateID">The ID of the candidate desired.</param>
 /// <param name="committeeID">The ID of a committee to search for.</param>
 /// <returns>A collection of all committees on record for the specified candidate with the specified committee ID (if provided).</returns>
 public List <Committee> GetCommittees(string candidateID, char?committeeID = null)
 {
     using (AuthorizedCommitteeTds ds = new AuthorizedCommitteeTds())
     {
         using (AuthorizedCommitteesTableAdapter ta = new AuthorizedCommitteesTableAdapter())
         {
             ta.FillCommitteeBy(ds.AuthorizedCommittees, candidateID, committeeID.HasValue ? committeeID.Value.ToString() : null);
         }
         List <Committee> comms = new List <Committee>(ds.AuthorizedCommittees.Count);
         foreach (AuthorizedCommitteeTds.AuthorizedCommitteesRow row in ds.AuthorizedCommittees.Rows)
         {
             if (string.IsNullOrWhiteSpace(row.CommitteeID))
             {
                 continue;
             }
             comms.Add(new Committee(row.CommitteeID.ToCharArray()[0]).LoadCommitteeData(row));
         }
         return(comms);
     }
 }
예제 #3
0
 /// <summary>
 /// Retrieves the CFIS ID of a candidate's primary committee for a specific election cycle.
 /// </summary>
 /// <param name="candidateID">The ID of the candidate desired.</param>
 /// <param name="electionCycle">The election cycle in which to search.</param>
 /// <returns>The CFIS ID of the candidate's primary committee if found, else null.</returns>
 public char?GetPrimaryCommitteeID(string candidateID, string electionCycle)
 {
     using (AuthorizedCommitteeTds ds = new AuthorizedCommitteeTds())
     {
         using (AuthorizedCommitteesTableAdapter ta = new AuthorizedCommitteesTableAdapter())
         {
             ta.Fill(ds.AuthorizedCommittees, candidateID, electionCycle);
         }
         foreach (AuthorizedCommitteeTds.AuthorizedCommitteesRow row in ds.AuthorizedCommittees.Rows)
         {
             if ("Y".Equals(row.IsPrincipal.Trim()))
             {
                 string id = row.CommitteeID.Trim();
                 if (!string.IsNullOrEmpty(id))
                 {
                     return(id.ToCharArray()[0]);
                 }
             }
         }
     }
     return(null);
 }
예제 #4
0
 /// <summary>
 /// Retrieves all bank accounts on record for the specified candidate, election cycle, and committee.
 /// </summary>
 /// <param name="candidateID">The ID of the candidate whose bank accounts are to be retrieved.</param>
 /// <param name="electionCycle">The election cycle in which to search.</param>
 /// <param name="committeeID">The ID of the committee whose bank accounts are to be retrieved.</param>
 /// <returns>A collection of all bank accounts on record for the specified candidate, election cycle, and committee, indexed by account ID.</returns>
 public Dictionary <byte, BankAccount> GetBankAccounts(string candidateID, string electionCycle, char committeeID)
 {
     using (AuthorizedCommitteeTds ds = new AuthorizedCommitteeTds())
     {
         using (BankAccountsTableAdapter ta = new BankAccountsTableAdapter())
         {
             ta.Fill(ds.BankAccounts, candidateID, electionCycle, committeeID.ToString());
         }
         Dictionary <byte, BankAccount> d = new Dictionary <byte, BankAccount>(ds.BankAccounts.Count);
         foreach (AuthorizedCommitteeTds.BankAccountsRow row in ds.BankAccounts.Rows)
         {
             byte id;
             if (byte.TryParse(row.BankAccountID, out id))
             {
                 d.Add(id, new BankAccount(id)
                 {
                     BankName                  = row.BankName.Trim(),
                     City                      = row.City.Trim(),
                     State                     = row.State.Trim(),
                     Zip                       = new ZipCode(row.Zip.Trim()),
                     Number                    = row.Number.Trim(),
                     Name                      = row.Name.Trim(),
                     OpeningDate               = row.IsOpeningDateNull() ? null : row.OpeningDate as DateTime?,
                     ClosingDate               = row.IsClosingDateNull() ? null : row.ClosingDate as DateTime?,
                     CurrentBalanceDate        = row.IsCurrentBalanceDateNull() ? null : row.CurrentBalanceDate as DateTime?,
                     CurrentBalance            = row.CurrentBalance,
                     Type                      = CPConvert.ToBankAccountType(row.AccountTypeCode.Trim()),
                     OtherTypeSpecification    = row.AccountTypeOther.Trim(),
                     Purpose                   = CPConvert.ToBankAccountPurpose(row.PurposeCode.Trim()),
                     OtherPurposeSpecification = row.PurposeOther.Trim()
                 });
             }
         }
         return(d);
     }
 }
예제 #5
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);
            }
        }