Example #1
0
 public ActionResult <IEnumerable <Team> > Get()
 {
     try
     {
         return(Ok(_ts.Get()));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
        private void UpdateScheduleStrength()
        {
            var teams = _teamsService.Get();
            var game  = _gameService.Get();

            foreach (var team in teams)
            {
                var fixtures = _fixturesService.GetTeamFixturesForSeason(team.Id, game.Season);
                var strength = 0;

                foreach (var fixture in fixtures)
                {
                    string opponent;

                    if (fixture.HomeTeamId == team.Id && fixture.Played)
                    {
                        opponent = fixture.AwayTeamId;
                    }
                    else
                    {
                        opponent = fixture.HomeTeamId;
                    }

                    var oppStandings = _standingsService.GetTeamStandings(opponent, game.Season);
                    strength += oppStandings.OverallWins;
                }

                _standingsService.UpdateScheduleWeight(team.Id, game.Season, strength);
            }
        }
Example #3
0
        private void CreateStandingsForNewSeason(int season)
        {
            List <TeamsDocument> _teams = _teamsService.Get();

            foreach (var team in _teams)
            {
                StandingsDocument newRecord = new StandingsDocument
                {
                    Season               = season,
                    TeamId               = team.Id,
                    Conference           = team.Conference,
                    Division             = team.Division,
                    DivisionRank         = 1,
                    ConferenceRank       = 1,
                    OverallRank          = 1,
                    OverallWins          = 0,
                    OverallLosses        = 0,
                    OverallTies          = 0,
                    OverallPct           = 0,
                    OverallPointsFor     = 0,
                    OverallPointsAgainst = 0,
                    HomeWins             = 0,
                    HomeLosses           = 0,
                    HomeTies             = 0,
                    AwayWins             = 0,
                    AwayLosses           = 0,
                    AwayTies             = 0,
                    DivisionWins         = 0,
                    DivisionLosses       = 0,
                    DivisionTies         = 0,
                    DivisionPct          = 0,
                    ConferenceWins       = 0,
                    ConferenceLosses     = 0,
                    ConferenceTies       = 0,
                    ConferencePct        = 0,
                    CurrentStreak        = 'W',
                    StreakLength         = 0,
                    LastFive             = new char[] { '-', '-', '-', '-', '-' },
                    ScheduleWeight       = 0
                };

                _standingsService.Create(newRecord);
            }
        }
Example #4
0
 public ActionResult <List <TeamsDocument> > GetTeams()
 {
     return(Ok(_teamsService.Get()));
 }
Example #5
0
 public ActionResult <List <Team> > GetAll() =>
 _teamsService.Get();