public IActionResult Index() { List <Athlete> allAthletes = _athleteRepository.GetAll(); List <AthletePerformance> allPerformances = _athletePerformanceRepository.GetAll(); List <Competition> allCompetitions = _competitionRepository.GetAll(); List <AthletePerformanceDto> result = (from performance in allPerformances join competition in allCompetitions on performance.CompetitionId equals competition.Id join athlete in allAthletes on performance.AthleteId equals athlete.Id select new AthletePerformanceDto { Id = performance.Id, AthleteName = athlete.Name, AthleteSurname = athlete.Surname, AthletePatronymicName = athlete.PatronymicName, CompetitionName = competition.Name, PerformanceDate = performance.PerformanceDate, Score = performance.Score }).ToList(); return(View(result)); }
public List <SplitResult> LoadResults(Race race) { _currentRace = race; SplitResults = new List <SplitResult>(); try { var athletes = _athleteRepository.GetAll(); //FindBy(x => x.Races.Any(y => y.Id == race.Id)); var splits = _splitRepository.FindBy(x => x.RaceId == race.Id && x.AthleteId > 0); foreach (var athlete in athletes) { foreach (var split in splits.Where(x => x.AthleteId == athlete.Id && x.RaceId == race.Id)) { var splitPosition = splits.Where(x => x.SplitLapCount == split.SplitLapCount).OrderBy(x => x.DateTimeOfDay).ThenBy(x => x.RaceTime).ToList().FindIndex(x => x.AthleteId == athlete.Id) + 1; var gendorPosition = splits.Where(x => x.SplitLapCount == split.SplitLapCount && x.Athlete.Gendor == athlete.Gendor).OrderBy(x => x.DateTimeOfDay).ThenBy(x => x.RaceTime).ToList().FindIndex(x => x.AthleteId == athlete.Id) + 1; var ageCatPosition = splits.Where(x => x.SplitLapCount == split.SplitLapCount && x.Athlete.AgeCategory == athlete.AgeCategory).OrderBy(x => x.DateTimeOfDay).ThenBy(x => x.RaceTime).ToList().FindIndex(x => x.AthleteId == athlete.Id) + 1; List <double> splitTimes = new List <double>(); foreach (var s in splits.Where(x => x.AthleteId == athlete.Id && x.RaceId == race.Id && x.SplitLapCount <= split.SplitLapCount)) { splitTimes.Add(s.SplitTime); } double doubleAverageTicks = splitTimes.Any() ? splitTimes.Average(timeSpan => timeSpan) : 0; TimeSpan avgLap = TimeSpan.FromMilliseconds(doubleAverageTicks); var splitResult = new SplitResult { OveralPosition = splitPosition, GendorPosition = gendorPosition, AgeCategoryPosition = ageCatPosition, AthleteName = split.AthleteName, AgeCategory = split.Athlete.AgeCategory, Bib = split.Bib, SplitTime = TimeSpan.FromMilliseconds(split.SplitTime).ToString("hh':'mm':'ss':'ff"), TimeOfDay = split.TimeOfDay, SplitName = split.SplitName, RaceTime = TimeSpan.FromTicks(split.RaceTime).ToString("hh':'mm':'ss':'ff"), // RaceTime2 = split.RaceTime2, LapNumber = split.SplitLapCount, Epc = split.Epc, RaceName = split.Race.Name, Rssi = split.Rssi, AverLap = avgLap.ToString("hh':'mm':'ss':'ff"), EstFinish = TimeSpan.FromSeconds(avgLap.Seconds * 25).ToString("hh':'mm':'ss':'ff"), }; SplitResults.Add(splitResult); } } SplitResults = SplitResults.OrderByDescending(x => x.LapNumber).ThenBy(x => x.OveralPosition).ToList(); } catch (Exception ex) { logger.Error(ex, "Error loading results" + ex.Message); } return(SplitResults); }
public AthleteManager() { Athletes = new ObservableCollection <Athlete>(_athleteRepository.GetAll()); _nextBib = 1; }
public void SetNewRace() { _athleteDictionary = _athleteRepository.GetAll().ToList().Distinct(new AthleteComparer()).ToDictionary(x => x.TagId, x => x); AthleteSplits.Clear(); }