public static Models.v0.FixtureBasic ToModel(this Entities.Fixture entity, IEnumerable <Entities.FixturePlayer> players)
        {
            if (entity == null)
            {
                return(null);
            }

            return(new Models.v0.FixtureBasic
            {
                HomeTeam = entity.HomeTeam.ToModel(),
                AwayTeam = entity.AwayTeam.ToModel(),
                Competition = entity.Competition.ToModel(),
                HomeGoals = entity.HomeGoals,
                AwayGoals = entity.AwayGoals,
                HomeShots = entity.HomeShots,
                AwayShots = entity.AwayShots,
                HomeShotsOnTarget = entity.HomeShotsOnTarget,
                AwayShotsOnTarget = entity.AwayShotsOnTarget,
                HomePlayers = players.Where(p => p.Team.Id == entity.HomeTeam.Id).ToModels().ToList(),
                AwayPlayers = players.Where(p => p.Team.Id == entity.AwayTeam.Id).ToModels().ToList(),
                DateTime = entity.DateTime,
                FixtureId = entity.FixtureId,
                Season = entity.Season
            });
        }
예제 #2
0
        public async Task ProcessMatchInfo(FixtureMatchInfo matchInfo, IDbConnection conn)
        {
            var teams = new List <Entities.Team>
            {
                new Entities.Team
                {
                    Id        = matchInfo.HomeTeamId,
                    Name      = matchInfo.HomeTeamName,
                    ShortName = string.Empty
                },
                new Entities.Team
                {
                    Id        = matchInfo.AwayTeamId,
                    Name      = matchInfo.AwayTeamName,
                    ShortName = string.Empty
                }
            };
            await _teamRepository.InsertMultipleAsync(teams, conn);

            var details = new Entities.Fixture
            {
                FixtureId          = matchInfo.Id,
                HomeDeep           = matchInfo.HomeDeepPasses,
                AwayDeep           = matchInfo.AwayDeepPasses,
                HomeWinForecast    = matchInfo.HomeWinForecast,
                DrawForecast       = matchInfo.DrawForecast,
                AwayWinForecast    = matchInfo.AwayWinForecast,
                HomePpda           = matchInfo.HomePpda,
                AwayPpda           = matchInfo.AwayPpda,
                AwayExpectedGoals  = matchInfo.AwayExpectedGoals,
                AwayExpectedPoints = matchInfo.AwayWinForecast * 3 + matchInfo.DrawForecast,
                AwayGoals          = matchInfo.AwayGoals,
                AwayShots          = matchInfo.AwayShots,
                AwayShotsOnTarget  = matchInfo.AwayShotsOnTarget,
                HomeExpectedGoals  = matchInfo.HomeExpectedGoals,
                HomeExpectedPoints = matchInfo.HomeWinForecast * 3 + matchInfo.DrawForecast,
                HomeGoals          = matchInfo.HomeGoals,
                HomeShots          = matchInfo.HomeShots,
                HomeShotsOnTarget  = matchInfo.HomeShotsOnTarget
            };

            await _fixtureRepository.Update(details, conn);
        }