Пример #1
0
        public async ValueTask <IEnumerable <MatchDayPrediction> > Handle(QueryAllMatchesPrediction query, CancellationToken token = default)
        {
            var fixtureQuery = new QueryGetMatchDayFixtures
            {
                Competition = query.Competition,
                Matchday    = query.Matchday,
                Season      = query.Season
            };

            var predictions = new List <MatchDayPrediction>();

            foreach (var match in await _fixturesQuery.Handle(fixtureQuery, token))
            {
                var prediction = ConsumeModel.Predict(new ModelInput
                {
                    HomeTeam = match.HomeTeam,
                    AwayTeam = match.AwayTeam
                });

                predictions.Add(new MatchDayPrediction
                {
                    HomeTeam    = match.HomeTeam,
                    AwayTeam    = match.AwayTeam,
                    Predictions = new Dictionary <string, float>
                    {
                        [match.HomeTeam] = prediction.Score[0] * 100,
                        [match.AwayTeam] = prediction.Score[1] * 100,
                        ["Draw"]         = prediction.Score[2] * 100,
                    }
                });
            }

            return(predictions);
        }
Пример #2
0
 public async Task <IActionResult> GetMatchDayFixtures([FromBody] QueryGetMatchDayFixtures query, CancellationToken token)
 {
     return(Ok(await _fixturesQuery.Handle(query, token)));
 }