public async Task <ActionResult <int> > GetDriversRacePositionTotalById(int id, int position) { var result = await _dataReader.GetDriversRaceResults(id); var mappedData = result.Select(x => RaceResults.MapFromDb(x)).ToList(); return(_calculate.RacePositionCount(mappedData, position)); }
private DriverCalculationInfo CalculateDriverData(List <RaceResults> driverResults) { var bestTrack = _calculate.DriversBestTrack(driverResults); var totalPoints = _calculate.TotalDriverPoints(driverResults); var currentSeasonPoints = _calculate.TotalDriverPointsOfASeason(driverResults, DateTime.Now.Year); var highestResult = _calculate.HighestResult(driverResults); var totalNumOfHighestResult = _calculate.RacePositionCount(driverResults, highestResult); var numRaceFastestLaps = _calculate.NumberOfRaceFastestLaps(driverResults); var numOfRacesCompleted = _calculate.NumberOfRacesCompleted(driverResults); var numDNFs = _calculate.NumberOfDnfs(driverResults); var totalLapsComplete = _calculate.TotalNumberOfLapsCompleted(driverResults); var bestSeason = _calculate.BestSeason(driverResults); var numChapionships = _calculate.NumberOfChampionshipsWon(driverResults); var TopTenFinishes = _calculate.TopTenPositionCount(driverResults); var numOfWins = _calculate.RacePositionCount(driverResults, 1); var numOfLapsLead = _calculate.LapsLead(driverResults); var numOfOvertakes = _calculate.Overtakes(driverResults); var calcData = new DriverCalculationInfo { BestTrack = bestTrack, TotalPoints = totalPoints, TotalPointsOfCurrentSeason = currentSeasonPoints, HighestResult = highestResult, TotalNumOfHighestResult = totalNumOfHighestResult, NumRaceFastestLaps = numRaceFastestLaps, NumChapionships = numChapionships, BestSeason = bestSeason, NumDNFs = numDNFs, NumOfRacesCompleted = numOfRacesCompleted, TotalLapsComplete = totalLapsComplete, TopTenFinishes = TopTenFinishes, NumOfRaceWins = numOfWins, LeadLaps = numOfLapsLead, Overtakes = numOfOvertakes }; return(calcData); }