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); }