private Vote VoteFromSunlightVote(SunlightVoteResult.SunlightVote v, string legislatorBioguideId) { try { var vote = new Vote() { Bill = v.bill == null ? null : BillFromSunlightBill(v.bill), BillId = v.bill_id ?? string.Empty, Chamber = DataTransformationUtil.LegislativeBodyFromSunlight(v.chamber), Question = v.question ?? string.Empty, Result = v.result, Source = v.source, //Type = new VoteType( v.vote_type ?? string.Empty, // DataTransformationUtil.VoteTypeKindFromSunlightVoteType(v.vote_type)), VotedAt = DataTransformationUtil.DateFromSunlightTime(v.voted_at), //Year = v.year ?? 0, VoteCastedByLegislator = DataTransformationUtil.VoteCasedTypeFromSunlight(v.voter_ids, legislatorBioguideId), NominationId = v.nomination_id ?? string.Empty, //Nomination = NominationFromSunlightNomination(v.nomination) }; return(vote); } catch (Exception ex) { _logger.Error("Error: Could not create Vote from Sunlight vote", ex); return(null); } }
public static List <Legislator> LegislatorsFromSunlightLegislatorResult(SunlightLegislatorResult.Rootobject legislatorResults) { var legislators = new List <Legislator>(); foreach (var l in legislatorResults.results) { var legislator = new Legislator() { FirstName = l.first_name ?? string.Empty, MiddleName = l.middle_name ?? string.Empty, LastName = l.last_name ?? string.Empty, Birthday = DataTransformationUtil.DateFromSunlightTime(l.birthday), Party = DataTransformationUtil.PartyFromString(l.party), Chamber = DataTransformationUtil.LegislativeBodyFromSunlight(l.chamber), State = DataTransformationUtil.GetStateOrTerritoryFromSunlight(l.state), Gender = DataTransformationUtil.GenderFromString(l.gender), TermStartDate = DataTransformationUtil.DateFromSunlightTime(l.term_start), TermEndDate = DataTransformationUtil.DateFromSunlightTime(l.term_end), IdBioguide = l.bioguide_id ?? string.Empty, OfficeAddress = string.IsNullOrWhiteSpace(l.office) ? new ContactMethod(ContactType.NotSet, string.Empty) : new ContactMethod(ContactType.Mail, l.office), OfficeNumber = string.IsNullOrWhiteSpace(l.phone) ? new ContactMethod(ContactType.NotSet, string.Empty) : new ContactMethod(ContactType.Phone, l.phone), Email = string.IsNullOrWhiteSpace(l.oc_email) ? new ContactMethod(ContactType.NotSet, string.Empty) : new ContactMethod(ContactType.Email, l.oc_email), FacebookId = string.IsNullOrWhiteSpace(l.facebook_id) ? new ContactMethod(ContactType.NotSet, string.Empty) : new ContactMethod(ContactType.Facebook, l.facebook_id), TwitterId = string.IsNullOrWhiteSpace(l.twitter_id) ? new ContactMethod(ContactType.NotSet, string.Empty) : new ContactMethod(ContactType.Twitter, l.twitter_id), YouTubeId = string.IsNullOrWhiteSpace(l.youtube_id) ? new ContactMethod(ContactType.NotSet, string.Empty) : new ContactMethod(ContactType.YouTube, l.youtube_id), Website = string.IsNullOrWhiteSpace(l.website) ? new ContactMethod(ContactType.NotSet, string.Empty) : new ContactMethod(ContactType.WebSite, l.website), ContactSite = string.IsNullOrWhiteSpace(l.contact_form) ? new ContactMethod(ContactType.NotSet, string.Empty) : new ContactMethod(ContactType.WebSiteContact, l.contact_form), TotalVotes = 0, MissedVotesPercent = 0, VotesWithPartyPercent = 0, Senority = string.Empty }; legislators.Add(legislator); } return(legislators); }
private static BillAction ActionFromSunlight(SunlightBillResult.Action action) { if (action == null) { return(null); } var billAction = new BillAction() { Date = DataTransformationUtil.DateFromSunlightTime(action.acted_at), Text = action.text ?? string.Empty }; return(billAction); }
private Nomination NominationFromSunlightNomination(SunlightVoteResult.SunlighNomination n) { if (n == null) { return(null); } var nomination = new Nomination() { DateOfLastAction = DataTransformationUtil.DateFromSunlightTime(n.last_action_at), DateReceived = DataTransformationUtil.DateFromSunlightTime(n.received_on), Organization = n.organization ?? string.Empty, Nominees = NomineesFromSunlightNominees(n.nominees) }; return(nomination); }
private Bill BillFromSunlightBill(SunlightBillResult.SunlightBill b) { try { var bill = new Bill() { Chamber = DataTransformationUtil.LegislativeBodyFromSunlight(b.chamber), Congress = b.congress ?? 0, //CosponsorIds = b.cosponsor_ids ?? new string[0], DateIntroduced = DataTransformationUtil.DateFromSunlightTime(b.introduced_on), DateOfLastVote = DataTransformationUtil.DateFromSunlightTime(b.last_vote_at), //History = HistoryFromSunlight(b.history), Id = b.bill_id ?? string.Empty, LastAction = ActionFromSunlight(b.last_action), Nicknames = b.Nicknames ?? new string[0], Number = b.number.ToString() ?? b.number.ToString(), SponsorId = b.sponsor_id ?? string.Empty, Summary = b.summary ?? string.Empty, //SummaryCappedAt1k = b.summary_short ?? string.Empty, Titles = new BillTitles() { OfficialTile = b.official_title ?? string.Empty, PopularTitlePerLoc = b.popular_title ?? string.Empty, ShortTitle = b.short_title ?? string.Empty } //, //Type = BillTypeFromSunlight(b.bill_type), //UpcomingActions = UpcomingBillActionFromSunlight(b.upcoming), //Urls = UrlsFromSunlightBillUrls(b.urls), //WithdrawnCosponsorIds = b.withdrawn_cosponsor_ids == null // ? new List<string>() // : new List<string>(b.withdrawn_cosponsor_ids) }; return(bill); } catch (Exception ex) { _logger.Error("Error encoutnered creating Bill from SunlightBill.", ex); return(null); } }
private static BillHistory HistoryFromSunlight(SunlightBillResult.History billHistory) { if (billHistory == null) { return(null); } var history = new BillHistory() { AwaitingSignature = billHistory.awaiting_signature, AwaitingSignatureSince = DataTransformationUtil.DateFromSunlightTime(billHistory.awaiting_signature_since), DateHouseLastVotedOnPassage = DataTransformationUtil.DateFromSunlightTime(billHistory.house_passage_result_at), DateSenateLastVotedOnPassage = DataTransformationUtil.DateFromSunlightTime(billHistory.senate_passage_result_at), DateEnacted = DataTransformationUtil.DateFromSunlightTime(billHistory.enacted_at), Enacted = billHistory.enacted, DateVetoed = DataTransformationUtil.DateFromSunlightTime(billHistory.vetoed_at), Vetoed = billHistory.vetoed, HousePassageResult = DataTransformationUtil.LegislativeBillVoteFromSunlight(billHistory.house_passage_result), SenatePassageResult = DataTransformationUtil.LegislativeBillVoteFromSunlight(billHistory.senate_passage_result) }; return(history); }
private static List <UpcomingAction> UpcomingBillActionFromSunlight(SunlightBillResult.Upcoming[] upcoming) { var upcomingActions = new List <UpcomingAction>(); if (upcoming == null) { return(upcomingActions); } foreach (var ua in upcoming) { var upcomingAction = new UpcomingAction() { Chamber = DataTransformationUtil.LegislativeBodyFromSunlight(ua.chamber), Context = ua.context ?? string.Empty, Date = DataTransformationUtil.DateFromSunlightTime(ua.scheduled_at), Url = ua.url ?? string.Empty }; upcomingActions.Add(upcomingAction); } return(upcomingActions); }
/* * public static List<Legislator> LegislatorsFromPropublicaLegislatorsResult(SenateMembersResult.Rootobject legislatorResults) * { * var legislators = new List<Legislator>(); * * var results = legislatorResults.results.FirstOrDefault(); * if (results == null) * return legislators; * * foreach (var l in results.members) * { * var legislator = new Legislator() * { * FirstName = l.first_name ?? string.Empty, * MiddleName = l.middle_name ?? string.Empty, * LastName = l.last_name ?? string.Empty, * Birthday = DataTransformationUtil.DateFromSunlightTime(l.date_of_birth), * Party = DataTransformationUtil.PartyFromString(l.party), * State = DataTransformationUtil.GetStateOrTerritoryFromSunlight(l.state), * OfficeAddress = string.IsNullOrWhiteSpace(l.office) * ? new ContactMethod(ContactType.NotSet, string.Empty) * : new ContactMethod(ContactType.Mail, l.office), * OfficeNumber = string.IsNullOrWhiteSpace(l.phone) * ? new ContactMethod(ContactType.NotSet, string.Empty) * : new ContactMethod(ContactType.Phone, l.phone), * FacebookId = string.IsNullOrWhiteSpace(l.facebook_account) * ? new ContactMethod(ContactType.NotSet, string.Empty) * : new ContactMethod(ContactType.Facebook, l.facebook_account), * TwitterId = string.IsNullOrWhiteSpace(l.twitter_account) * ? new ContactMethod(ContactType.NotSet, string.Empty) * : new ContactMethod(ContactType.Twitter, l.twitter_account), * YouTubeId = string.IsNullOrWhiteSpace(l.youtube_account) * ? new ContactMethod(ContactType.NotSet, string.Empty) * : new ContactMethod(ContactType.YouTube, l.youtube_account), * Website = string.IsNullOrWhiteSpace(l.url) * ? new ContactMethod(ContactType.NotSet, string.Empty) * : new ContactMethod(ContactType.WebSite, l.url), * ContactSite = string.IsNullOrWhiteSpace(l.contact_form) * ? new ContactMethod(ContactType.NotSet, string.Empty) * : new ContactMethod(ContactType.WebSiteContact, l.contact_form), * IdBioguide = l.id ?? string.Empty, * * * // RM: These do not exist in new ProPublica source * Gender = Gender.NA, * TermStartDate = DateTime.MinValue, * TermEndDate = DateTime.MinValue, * Email = new ContactMethod(ContactType.NotSet, string.Empty), * * * // Verify adn add checking for these values * TotalVotes = l.total_votes ?? 0, * MissedVotesPercent = l.missed_votes_pct ?? 0, * VotesWithPartyPercent = l.votes_with_party_pct ?? 0, * Senority = l.seniority ?? string.Empty * }; * * // RM: Newlsy added, verify this works * // FIX: type will be root since it is serialized as such. * var typeOfMember = l.GetType(); * if (typeOfMember == typeof(SenateMember)) * legislator.Chamber = LegislativeBody.Senate; * else if (typeOfMember == typeof(CongressMember)) * legislator.Chamber = LegislativeBody.House; * else * legislator.Chamber = LegislativeBody.Unknown; * * legislators.Add(legislator); * } * * return legislators; * } */ public static List <Committee> CommitteesFromSunlightCommitteeResult(SunlightCommitteeResult.Rootobject committeeResults) { var committees = new List <Committee>(); foreach (var c in committeeResults.results) { var committee = new Committee() { Id = c.committee_id ?? string.Empty, Name = c.name ?? string.Empty, Chamber = DataTransformationUtil.LegislativeBodyFromSunlight(c.chamber), IsSubcommittee = c.subcommittee, ParentCommitteeId = c.subcommittee ? (c.parent_committee_id ?? string.Empty) : string.Empty, Phone = c.phone ?? string.Empty, Url = c.url ?? string.Empty }; committees.Add(committee); } return(committees); }