/// <summary> /// Raises the <see cref="Control.Load"/> event. /// </summary> /// <param name="e">An <see cref="EventArgs"/> object that contains the event data.</param> protected override void OnLoad(EventArgs e) { this.EnsureChildControls(); // set up committee list _committeeList.Items.Clear(); foreach (char id in _dsh.CommitteeNames.Keys) { _committeeList.Items.Add(new ListItem(string.Format("{0} ({1})", _dsh.CommitteeNames[id], id), id.ToString())); } // show default committee, else show first committee char?primaryID = AuthorizedCommittee.GetPrimaryCommitteeID(CPProfile.Cid, CPProfile.ElectionCycle); if (primaryID.HasValue) { ListItem item = _committeeList.Items.FindByValue(primaryID.Value.ToString()); if (!object.Equals(item, null)) { item.Selected = true; FilterByCommittee(null, null); } } else { _committeeList.SelectedIndex = 0; FilterByCommittee(null, null); } }
public static CommitteeProfileViewModel CommitteeProfileFrom(AuthorizedCommittee comm) { if (comm == null) { return new CommitteeProfileViewModel { ContactInfo = new ContactInfoViewModel(), MailingAddress = new AddressViewModel(), Treasurer = new CampaignStaffViewModel() } } ; return(new CommitteeProfileViewModel { ID = comm.ID, Name = comm.Name, ContactInfo = ContactInfoFrom(comm, urls: comm.WebsiteUrl, hasUrls: true), IsPrincipal = comm.IsPrincipal, IsActive = comm.IsActive, BoeAuthDate = comm.BoeDate, TerminationDate = comm.TerminationDate, MailingAddress = AddressFrom(comm.MailingAdress), Treasurer = CampaignStaffFrom(comm.Treasurer), // previous election LastElectionDate = comm.LastElectionDate, LastOfficeSought = comm.LastElectionOffice, LastDistrict = comm.LastElectionDistrict, LastPrimaryParty = comm.LastPrimaryParty }); }
/// <summary> /// Event handler for updating control fields with the details of a campaign bank account. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">An <see cref="EventArgs"/> object that contains the event data.</param> protected void ShowBankAccount(object sender, EventArgs e) { BankAccount ba; byte id = 0; if (byte.TryParse(_bankAccountsList.SelectedValue.Substring(1), out id) && (id > 0)) { string committeeID = _bankAccountsList.SelectedValue.Substring(0, 1); AuthorizedCommittee ac = GetAuthorizedCommittee(committeeID); // fetch bank account if (!ac.BankAccounts.TryGetValue(id, out ba)) { _bankError.Text = "Sorry, the requested bank account could not be retrieved."; _bankError.Visible = true; _bankAccountDetails.Visible = false; return; } if (ba == null) { // error: no bank accounts _bankError.Text = string.Format("You do not currently have any bank accounts affiliated with your campaign for the {0} election", CPProfile.ElectionCycle); _bankError.Visible = true; _bankAccountDetails.Visible = false; } else { // show bank account data _bankError.Visible = false; _bankAccountDetails.Visible = true; _bankName.Value = ba.BankName; _bankCity.Value = ba.City; _bankState.Value = ba.State; _bankZip.Value = (ba.Zip != null) ? ba.Zip.ToString() : null; _dateOpened.Value = ba.OpeningDate.HasValue ? ba.OpeningDate.Value.ToDateString() : null; _dateClosed.Value = ba.ClosingDate.HasValue ? ba.ClosingDate.Value.ToDateString() : null; _balance.Value = ba.CurrentBalance.ToString("C", CultureInfo.CurrentCulture); _balanceDate.Value = ba.CurrentBalanceDate.HasValue ? ba.CurrentBalanceDate.Value.ToDateString() : null; _accountNumber.Value = ba.Number; _accountName.Value = ba.Name; _directDeposit.Value = ba.HasDirectDeposit ? "Yes" : "No"; _accountType.Value = ba.Type == BankAccountType.Other ? ba.OtherTypeSpecification : CPConvert.ToString(ba.Type); _accountPurpose.Value = ba.Purpose == BankAccountPurpose.Other ? ba.OtherPurposeSpecification : CPConvert.ToString(ba.Purpose); } } else { _bankAccountDetails.Visible = false; } _bankAccountsUpdatePanel.Update(); }
/// <summary> /// Updates control fields with an authorized committee's details. /// </summary> /// <param name="id">The CFIS ID of the authorized committee to display.</param> private void ShowCommittee(char?id) { AuthorizedCommittee ac = id.HasValue ? GetAuthorizedCommittee(id.Value) : GetDefaultCommittee(); if (ac == null) { _errorMessage.Text = "Sorry, the committee you have requested could not be retrieved."; _errorMessage.Visible = true; _committeeDetails.Visible = false; } else { ShowCommittee(ac); } }
// GET: Profile/Committee/Details/L public ActionResult Details(char?id) { if (id == null) { return(RedirectToAction(ActionName_Principal)); } AuthorizedCommittee comm = null; if (id.HasValue) { comm = FindCommittee(id.Value); } if (comm != null) { return(View(ProfileViewModelFactory.CommitteeProfileFrom(comm))); } return(HttpNotFound()); }
// GET: Filings/DisclosureStatements public ActionResult Index(char?committeeID, byte?statementNumber) { bool idSpecified = committeeID.HasValue || statementNumber.HasValue; var data = GetDisclosureStatementData(); if (!committeeID.HasValue) { committeeID = AuthorizedCommittee.GetPrimaryCommitteeID(CPProfile.Cid, CPProfile.ElectionCycle); } if (committeeID.HasValue && data != null && data.CommitteeNames.ContainsKey(committeeID.Value)) { var statements = data.CommitteeStatements[committeeID.Value].Values; if (statements.Any()) { return(Statement(committeeID.Value, statements.Max(s => s.Number))); } } return(View()); }
/// <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); } }
/// <summary> /// Gets the ID for a committee treasurer. /// </summary> /// <param name="c">The <see cref="AuthorizedCommittee"/> affiliated with the treasurer.</param> /// <returns>An identifier for the treasurer of committee <paramref name="c"/>.</returns> private string GetTreasurerID(AuthorizedCommittee c) { return((c != null) ? TreasurerPrefix + c.ID + _electionCycle : string.Empty); }
/// <summary> /// Event handler for updating control fields with a campaign liaison's details. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">An <see cref="EventArgs"/> object that contains the event data.</param> protected void ShowLiaison(object sender, EventArgs e) { Liaison l; PostalAddress address; byte id = 0; if (byte.TryParse(_liaisonList.SelectedValue.Substring(1), out id) && (id > 0)) { string committeeID = _liaisonList.SelectedValue.Substring(0, 1); AuthorizedCommittee ac = GetAuthorizedCommittee(committeeID); // fetch liaison if (!ac.Liaisons.TryGetValue(id, out l)) { _liaisonError.Text = "Sorry, the requested campaign contact could not be retrieved."; _liaisonError.Visible = true; _liaisonDetails.Visible = false; return; } if (l == null) { // error: no liaisons _liaisonError.Text = string.Format("You do not currently have any campaign liaisons or consultants for the {0} election.", CPProfile.ElectionCycle); _liaisonError.Visible = true; _liaisonDetails.Visible = false; } else { // show liaison data _liaisonError.Visible = false; _liaisonDetails.Visible = true; _liaisonType.Value = l.LiaisonType.ToString <LiaisonType>(); _liaisonOrder.Value = CPConvert.ToString(l.ContactOrder); _liaisonSalutation.Value = CPConvert.ToString(l.Honorific); _liaisonLastName.Value = l.LastName; _liaisonFirstName.Value = l.FirstName; _liaisonMiddleInitial.Value = l.MiddleInitial.HasValue ? l.MiddleInitial.Value.ToString() : null; address = l.Address; if (address != null) { _liaisonStreetNumber.Value = address.StreetNumber; _liaisonStreetName.Value = address.StreetName; _liaisonApartment.Value = address.Apartment; _liaisonCity.Value = address.City; _liaisonState.Value = CPConvert.ParseStateCode(address.State); _liaisonZip.Value = (address.Zip != null) ? address.Zip.ToString() : null; } else { _liaisonStreetNumber.Value = _liaisonStreetName.Value = _liaisonApartment.Value = _liaisonCity.Value = _liaisonState.Value = _liaisonZip.Value = null; } _liaisonDaytimePhone.Value = (l.DaytimePhone != null) ? l.DaytimePhone.ToString() : null; _liaisonEveningPhone.Value = (l.EveningPhone != null) ? l.EveningPhone.ToString() : null; _liaisonFax.Value = (l.Fax != null) ? l.Fax.ToString() : null; _liaisonEmail.Value = l.Email; _liaisonManagerial.Value = l.HasManagerialControl ? "Yes" : "No"; _liaisonVG.Value = l.IsVGLiaison ? "Yes" : "No"; _entityName.Visible = l.LiaisonType == LiaisonType.Consultant; _entityName.Value = l.EntityName; } } else { _liaisonDetails.Visible = false; } _liaisonUpdatePanel.Update(); }
/// <summary> /// Updates control fields with an authorized committee's details. /// </summary> /// <param name="ac">The authorized committee to display.</param> private void ShowCommittee(AuthorizedCommittee ac) { PostalAddress address; if (ac == null) { _errorMessage.Text = string.Format("You do not currently have any committees authorized for the {0} election.", CPProfile.ElectionCycle); _errorMessage.Visible = true; _committeeDetails.Visible = false; } else { // show committee data _committeeDetails.Visible = true; // committee info _principal.Value = ac.IsPrincipal ? "Yes" : "No"; _active.Value = ac.IsActive ? "Yes" : "No"; _boeDate.Value = (ac.BoeDate != null) ? ((DateTime)ac.BoeDate).ToDateString() : null; _terminationDate.Value = (_terminationDate.Visible = (ac.TerminationDate != null)) ? ((DateTime)ac.TerminationDate).ToDateString() : null; // address info address = ac.Address; if (address != null) { _StreetNumber.Value = address.StreetNumber; _StreetName.Value = address.StreetName; _Apartment.Value = address.Apartment; _City.Value = address.City; _State.Value = CPConvert.ParseStateCode(address.State); _Zip.Value = (address.Zip != null) ? address.Zip.ToString() : null; } else { _StreetNumber.Value = _StreetName.Value = _Apartment.Value = _City.Value = _State.Value = _Zip.Value = null; } // last election info _lastDate.Value = (ac.LastElectionDate != null) ? ((DateTime)ac.LastElectionDate).ToDateString() : null; _lastOffice.Value = ac.LastElectionOffice; _lastDistrict.Value = ac.LastElectionDistrict; _lastParty.Value = ac.LastPrimaryParty; // mailing address info address = ac.MailingAdress; if (address != null) { _mailingLine1.Value = address.AddressLine1; _mailingStreetNumber.Value = address.StreetNumber; _mailingStreetName.Value = address.StreetName; _mailingApartment.Value = address.Apartment; _mailingCity.Value = address.City; _mailingState.Value = CPConvert.ParseStateCode(address.State); _mailingZip.Value = (address.Zip != null) ? address.Zip.ToString() : null; } else { _mailingLine1.Value = _mailingStreetNumber.Value = _mailingStreetName.Value = _mailingApartment.Value = _mailingCity.Value = _mailingState.Value = _mailingZip.Value = null; } // contact info _daytimePhone.Value = (ac.DaytimePhone != null) ? ac.DaytimePhone.ToString() : null; _eveningPhone.Value = (ac.EveningPhone != null) ? ac.EveningPhone.ToString() : null; _fax.Value = (ac.Fax != null) ? ac.Fax.ToString() : null; _email.Value = (!string.IsNullOrWhiteSpace(ac.Email)) ? string.Format("<a href=\"mailto:{0}\">{0}</a>", ac.Email) : null; if (!string.IsNullOrWhiteSpace(ac.WebsiteUrl)) { string url = ac.WebsiteUrl; if (!url.StartsWith("http://")) { url = "http://" + url; } _webUrl.Value = string.Format("<a href=\"{0}\" target=\"_blank\">{0}</a>", url); } else { _webUrl.Value = null; } // treasurer info Entity treasurer = ac.Treasurer; if (treasurer != null) { _salutation.Value = CPConvert.ToString(treasurer.Honorific); _lastName.Value = treasurer.LastName; _firstName.Value = treasurer.FirstName; _mi.Value = treasurer.MiddleInitial.HasValue ? treasurer.MiddleInitial.Value.ToString() : null; _contactOrder.Value = treasurer.ContactOrder.ToString(); address = treasurer.Address; if (address != null) { _treasStreetNumber.Value = address.StreetNumber; _treasStreetName.Value = address.StreetName; _treasApartment.Value = address.Apartment; _treasCity.Value = address.City; _treasState.Value = CPConvert.ParseStateCode(address.State); _treasZip.Value = (address.Zip != null) ? address.Zip.ToString() : null; } else { _treasStreetNumber.Value = _treasStreetName.Value = _treasApartment.Value = _treasCity.Value = _treasState.Value = _treasZip.Value = null; } _treasDaytimePhone.Value = (treasurer.DaytimePhone != null) ? treasurer.DaytimePhone.ToString() : null; _treasEveningPhone.Value = (treasurer.EveningPhone != null) ? treasurer.EveningPhone.ToString() : null; _treasFax.Value = (treasurer.Fax != null) ? treasurer.Fax.ToString() : null; _treasEmail.Value = !string.IsNullOrWhiteSpace(treasurer.Email) ? string.Format("<a href=\"mailto:{0}\">{0}</a>", treasurer.Email) : null; // treasurer employer info Entity employer = treasurer.Employer; if (employer != null) { _empName.Value = employer.LastName; address = employer.Address; if (address != null) { _empStreetNumber.Value = address.StreetNumber; _empStreetName.Value = address.StreetName; _empCity.Value = address.City; _empState.Value = CPConvert.ParseStateCode(address.State); _empZip.Value = (address.Zip != null) ? address.Zip.ToString() : null; } else { _empStreetNumber.Value = _empStreetName.Value = _empCity.Value = _empState.Value = _empZip.Value = null; } _empPhone.Value = (employer.DaytimePhone != null) ? employer.DaytimePhone.ToString() : null; _empFax.Value = (employer.Fax != null) ? employer.Fax.ToString() : null; } else { _empName.Value = _empStreetNumber.Value = _empStreetName.Value = _empCity.Value = _empState.Value = _empZip.Value = _empPhone.Value = _empFax.Value = _empPhone.Value = _empFax.Value = null; } } else { _treasStreetNumber.Value = _treasStreetName.Value = _treasApartment.Value = _treasCity.Value = _treasState.Value = _treasZip.Value = _treasDaytimePhone.Value = _treasEveningPhone.Value = _treasFax.Value = null; } // update liaison list _liaisonError.Visible = false; _liaisonDetails.Visible = false; ListItem item = _liaisonList.Items[0]; _liaisonList.Items.Clear(); _liaisonList.Items.Add(item); foreach (Liaison l in ac.Liaisons.Values) { string name = l.Name; if (l.LiaisonType == LiaisonType.Consultant) { name += " *"; } _liaisonList.Items.Add(new ListItem(name, ac.ID + l.ID.ToString())); } // update bank accounts list _bankError.Visible = false; _bankAccountDetails.Visible = false; item = _bankAccountsList.Items[0]; _bankAccountsList.Items.Clear(); _bankAccountsList.Items.Add(item); foreach (BankAccount ba in ac.BankAccounts.Values) { _bankAccountsList.Items.Add(new ListItem(string.Format("{0} ({1})", ba.BankName, ba.Number), ac.ID + ba.ID.ToString())); } } }