//add custom includes public Tour LoadTour(int?tourId) { var fetchStrategies = new IFetchStrategy <Tour>[] { new FetchMatchesWithPredictionsWithExperts() }; return(_context.GetTours(fetchStrategies).Single(t => t.TourId == tourId)); }
public IReadOnlyList <string> GenerateMeanPredictions(int tourId) { var fetchStrategies = new IFetchStrategy <Tour>[] { new FetchMatchesWithPredictions() }; var tour = _context.GetTours(fetchStrategies).AsNoTracking().Single(t => t.TourId == tourId); var matches = tour.Matches; var scores = new List <string>(); foreach (var match in matches) { var homeSum = 0; var awaySum = 0; var matchNumber = matches.Count; foreach (var prediction in match.Predictions) { homeSum += PredictionEvaluator.GetHomeGoals(prediction.Value); awaySum += PredictionEvaluator.GetAwayGoals(prediction.Value); } var homeMean = homeSum / matchNumber; var awayMean = awaySum / matchNumber; scores.Add(homeMean + ":" + awayMean); } return(scores); }
public List <MatchStat> GenerateMatchStats(int tourId) { var fetchStrategies = new IFetchStrategy <Tour>[] { new FetchMatchesWithHomeTeam(), new FetchMatchesWithAwayTeam(), new FetchMatchesWithPredictions() }; var tour = Queryable.Single <Tour>(_context.GetTours(fetchStrategies), t => t.TourId == tourId); if (!tour.IsClosed) { return(null); } var matches = tour.Matches; var matchStats = new List <MatchStat>(); foreach (var match in matches) { double predictionAverageSum = 0; var predictionValues = new HashSet <string>(); foreach (var prediction in match.Predictions) { predictionAverageSum += prediction.Sum; predictionValues.Add(prediction.Value); } predictionAverageSum /= match.Predictions.Count; var differentPredictions = predictionValues.Count; matchStats.Add(new MatchStat( match.HomeTeam.Title, match.AwayTeam.Title, Math.Round(predictionAverageSum, 2), differentPredictions)); } return(matchStats); }
public List <string> GenerateOrderedTeamTitlelist(int tourId) { var fetchStrategies = new IFetchStrategy <Tour>[] { new FetchMatchesWithHomeTeam(), new FetchMatchesWithAwayTeam() }; var tour = Queryable.Single <Tour>(_context.GetTours(fetchStrategies), t => t.TourId == tourId); var matches = tour.Matches; var teamlist = new List <string>(); matches.ForEach(m => { teamlist.Add(m.HomeTeam.Title); teamlist.Add(m.AwayTeam.Title); }); return(teamlist); }
//not sure public List <Tuple <Expert, int> > GenerateTourPreresultlist(int tourId) { //var tour = EagerLoad(tourId, t => t.Matches.Select(m => m.Predictions)); var fetchStrategies = new IFetchStrategy <Tour>[] { new FetchMatchesWithPredictions() }; var tour = _context.GetTours(fetchStrategies).Single(t => t.TourId == tourId); var matches = tour.Matches; var predictions = matches.SelectMany(m => m.Predictions).ToList(); var experts = _context.Experts.ToList(); var tourPreresultList = new List <Tuple <Expert, int> >(); for (var i = 0; i < experts.Count(); i++) { tourPreresultList.Add( new Tuple <Expert, int>( experts[i], predictions.Count(p => p.ExpertId == experts[i].ExpertId && !string.IsNullOrEmpty(p.Value)))); } return(tourPreresultList); }
public IList <Match> GetMatchesByTourId(int tourId) { var fetchStrategies = new IFetchStrategy <Tour>[] { new FetchMatches() }; return(_context.GetTours(fetchStrategies).TourById(tourId).Matches); }