private static void MergePrimaryWinners(string generalElectionKey, DateTime primaryElectionDate, bool isRunoff, ref int candidateDuplicates, ref int candidatesAdded) { var offices = ElectionsPoliticians .GetPrimaryWinnersForGeneralElection(generalElectionKey, primaryElectionDate, isRunoff).GroupBy(r => r.OfficeKey); foreach (var o in offices) { foreach (var c in o) { if (ElectionsPoliticians.ElectionKeyOfficeKeyPoliticianKeyExists( generalElectionKey, c.OfficeKey, c.PoliticianKey)) { candidateDuplicates++; } else { Elections.ActualizeElection(generalElectionKey); ActualizeElectionOffice(generalElectionKey, c.OfficeKey); ElectionsPoliticians.Insert(generalElectionKey, c.OfficeKey, c.PoliticianKey, c.RunningMateKey, Elections.GetStateElectionKeyFromKey(generalElectionKey), Empty, c.StateCode, c.CountyCode, c.LocalKey, c.DistrictCode, 0, false, OfficesOfficials.OfficeKeyPoliticianKeyExists(c.OfficeKey, c.PoliticianKey), false, Empty, null, null, null, Empty, false, DefaultDbDate, Empty, Empty, false); candidatesAdded++; } } } }
private static void MergePrimaryWinners(string generalElectionKey, DateTime primaryElectionDate, bool isRunoff, ref int candidateDuplicates, ref int candidatesAdded /*, ref int candidatesSkippedOfficeMissing*/) { var offices = ElectionsPoliticians.GetPrimaryWinnersForGeneralElection( generalElectionKey, primaryElectionDate, isRunoff) .GroupBy(r => r.OfficeKey); foreach (var o in offices) { //var office = o.First(); //if (ElectionsOffices.ElectionKeyOfficeKeyExists(generalElectionKey, // office.OfficeKey)) foreach (var c in o) { if ( ElectionsPoliticians.ElectionKeyOfficeKeyPoliticianKeyExists( generalElectionKey, c.OfficeKey, c.PoliticianKey)) { candidateDuplicates++; } else { Elections.ActualizeElection(generalElectionKey); ActualizeElectionOffice(generalElectionKey, c.OfficeKey); ElectionsPoliticians.Insert(generalElectionKey, c.OfficeKey, c.PoliticianKey, c.RunningMateKey, Elections.GetStateElectionKeyFromKey(generalElectionKey), string.Empty, Elections.GetCountyElectionKeyFromKey(generalElectionKey), Elections.GetLocalElectionKeyFromKey(generalElectionKey), c.StateCode, c.CountyCode, c.LocalCode, c.DistrictCode, 0, false, OfficesOfficials.OfficeKeyPoliticianKeyExists(c.OfficeKey, c.PoliticianKey), false); candidatesAdded++; } } // else candidatesSkippedOfficeMissing += o.Count(); } }