예제 #1
0
        private void GetTeams()
        {
            using (var Content = new DataClassesDataContext())
            {
                var list = Content.Teams;

                foreach (var team in list)
                {
                    Teams.Add(new TeamModel()
                    {
                        TeamID        = team.TeamID,
                        Name          = team.TeamName,
                        Division      = team.League1.LeagueName + " " + team.Division1.DivisionName,
                        OpponentsList = (from t in Content.Teams
                                         select new OpponentModel()
                        {
                            OpponentTeamID = t.TeamID,
                            OpponentTeamName = t.TeamName,
                        }).ToList()
                    });
                }
            }
        }
예제 #2
0
        private void GetData()
        {
            using (var Content = new DataClassesDataContext())
            {
                if (!Content.Uploads.Any())
                {
                    MessageBox.Show("There are no uploads, so there is no data.", "Upload Something!",
                                    MessageBoxButtons.OK);
                    return;
                }
                var list = Content.Teams;

                foreach (var team in list)
                {
                    Teams.Add(new TeamModel()
                    {
                        TeamID        = team.TeamID,
                        Name          = team.TeamName,
                        Division      = team.League1.LeagueName + " " + team.Division1.DivisionName,
                        OpponentsList = (from t in Content.OpponentsRecords
                                         where t.TeamID.Equals(team.TeamID) &&
                                         t.SeasonID.Equals(_SeasonID)
                                         select new OpponentModel()
                        {
                            OpponentTeamName = t.Team.TeamName,
                            OpponentTeamID = t.OpponentTeamID,
                            WinsVersus = t.WinsAgainst,
                            LossesVersus = t.LossesAgainst,
                        }).ToList(),
                        Wins                           = team.Records.FirstOrDefault(x => x.SeasonID == _SeasonID).Wins,
                        Losses                         = team.Records.FirstOrDefault(x => x.SeasonID == _SeasonID).Losses,
                        PythWins                       = team.Records.FirstOrDefault(x => x.SeasonID == _SeasonID).PythWins,
                        PythLosses                     = team.Records.FirstOrDefault(x => x.SeasonID == _SeasonID).PythLosses,
                        RPI                            = (float)team.TeamCalculations.OrderByDescending(x => x.UploadID).FirstOrDefault(x => x.SeasonID == _SeasonID).RPI,
                        StrengthOfSchedule             = (float)team.TeamCalculations.OrderByDescending(x => x.UploadID).FirstOrDefault(x => x.SeasonID == _SeasonID).SoS,
                        OpponentsWinPercentage         = (float)team.TeamCalculations.OrderByDescending(x => x.UploadID).FirstOrDefault(x => x.SeasonID == _SeasonID).OWP,
                        OpponentsOpponentWinPercentage =
                            (float)team.TeamCalculations.OrderByDescending(x => x.UploadID).FirstOrDefault(x => x.SeasonID == _SeasonID).OOWP,
                        PythOpponentsWinPercentage         = (float)team.TeamCalculations.OrderByDescending(x => x.UploadID).FirstOrDefault(x => x.SeasonID == _SeasonID).PythOWP,
                        PythOpponentsOpponentWinPercentage =
                            (float)team.TeamCalculations.OrderByDescending(x => x.UploadID).FirstOrDefault(x => x.SeasonID == _SeasonID).PythOOWP,
                        PythRPI = (float)team.TeamCalculations.OrderByDescending(x => x.UploadID).FirstOrDefault(x => x.SeasonID == _SeasonID).PythRPI,
                    });
                }

                foreach (var teamModel in Teams)
                {
                    var currentUpload = Content.Uploads.OrderByDescending(
                        x => x.UploadID).FirstOrDefault(x => x.SeasonID == _SeasonID);

                    if (currentUpload != null)
                    {
                        var previousUpload =
                            Content.Uploads.FirstOrDefault(x => x.UploadID == (currentUpload.UploadID - 1));

                        if (previousUpload != null)
                        {
                            teamModel.PreviousRPI = (float)Content.TeamCalculations.FirstOrDefault(
                                x => x.UploadID == previousUpload.UploadID && x.TeamID == teamModel.TeamID).RPI;

                            teamModel.RPIDiff = teamModel.RPI - teamModel.PreviousRPI;
                        }
                    }
                }

                foreach (var teamModel in Teams)
                {
                    teamModel.RoundData();
                }

                foreach (var teamModel in Teams)
                {
                    teamModel.CalcRanks(Teams);
                }
            }
        }