public async Task PopulateWithAthletesAsync(AthletesManager athletesManager, int year) { this.Records.Clear(); foreach (var athlete in athletesManager.Athletes) { var record = new Record(athlete.Name); var fastestParkrun5km = athletesManager.GetQuickestParkrunLastYear(athlete, year); record.FiveKm.SetTime(fastestParkrun5km); record.TenKm = await AthletesManager.GetTimeAsync(RaceDistance.TenKm, fastestParkrun5km); record.TenMiles = await AthletesManager.GetTimeAsync(RaceDistance.TenMiles, fastestParkrun5km); record.HalfMarathon = await AthletesManager.GetTimeAsync(RaceDistance.HalfMarathon, fastestParkrun5km); this.Records.Add(record); } }
private async Task UpdateAsync() { var record = this.GetSelectedRecord(); if (record == null) { return; } var fastestParkrun5km = this.ucTime5km.Time; if (fastestParkrun5km == TimeSpan.Zero) { var startDate = new DateTime(year - 1, 1, 1); var endDate = new DateTime(year - 1, 12, 31); try { fastestParkrun5km = athletesManager.GetQuickestParkrun(record.Name, startDate, endDate); } catch { MessageBox.Show($"Unable to get parkrun times for {record.Name} between {startDate} and {endDate}"); return; } } record.FiveKm = await AthletesManager.GetTimeAsync(RaceDistance.FiveKm, fastestParkrun5km, fastestParkrun5km); record.TenKm = await AthletesManager.GetTimeAsync(RaceDistance.TenKm, fastestParkrun5km, this.ucTime10km.Time); record.TenMiles = await AthletesManager.GetTimeAsync(RaceDistance.TenMiles, fastestParkrun5km, this.ucTime10m.Time); record.HalfMarathon = await AthletesManager.GetTimeAsync(RaceDistance.HalfMarathon, fastestParkrun5km, this.ucTimeHalfM.Time); UpdateSelectedRecordUI(); }