private static void PopulateResults(Meet meet) { foreach (var @event in File.Events) { var eventName = @event.EventInfo.Name.TranslateEventName(); if (eventName != "SKIP") { var gender = @event.EventInfo.Gender.TranslateGender(); var dbEvent = GetEvent(eventName, gender); PopulateAthletesAndPerformances(@event.EventResults, dbEvent, meet); } } }
private static void PopulateAthletesAndPerformances(IList <EventResult> eventResults, TrackAndFieldEvent dbEvent, Meet meet) { foreach (var result in eventResults) { var school = result.SchoolName.TranslateSchool(SchoolLookup); if (school != "SKIP") { var dbSchool = GetSchool(school); var performance = GetOrCreatePerformance(dbEvent.Id, dbSchool.Id, meet.Id, (decimal)result.Performance.Data, meet.Date, dbEvent.IsRunningEvent); if (dbEvent.IsRelayEvent) { if (result is RelayResult relayResult) { // go through the legs foreach (var leg in relayResult.LegInfo.Legs) { var firstName = leg.AthleteName.GetFirstName(); var lastName = leg.AthleteName.GetLastName(); var year = leg.AthleteYear.ParseYear(); var athlete = GetOrCreateAthlete(firstName, lastName, year, dbSchool, dbEvent.Gender); var athletePerformance = GetOrCreateAthletePerformance(athlete.Id, performance.Id); } } } else { if (result is IndividualResult individualResult) { var firstName = individualResult.AthleteName.GetFirstName(); var lastName = individualResult.AthleteName.GetLastName(); var year = individualResult.AthleteYear.ParseYear(); var athlete = GetOrCreateAthlete(firstName, lastName, year, dbSchool, dbEvent.Gender); var athletePerformance = GetOrCreateAthletePerformance(athlete.Id, performance.Id); } } } } }