Ejemplo n.º 1
0
 public void InsertTeamMember(RankedTeam team, Player player)
 {
     using (OracleConnection connection = Connection)
     {
         string Insert = "INSERT INTO TEAMMEMBER (loginName, teamName) VALUES (:LOGINNAME, :TEAMNAME)";
         using (OracleCommand command = new OracleCommand(Insert, connection))
         {
             command.Parameters.Add(new OracleParameter("LOGINNAME", team.TeamName));
             command.Parameters.Add(new OracleParameter("TEAMNAME", player.LoginName));
             command.ExecuteNonQuery();
         }
     }
 }
Ejemplo n.º 2
0
 public void InsertTeam(RankedTeam team)
 {
     using (OracleConnection connection = Connection)
     {
         string Insert = "INSERT INTO RANKEDTEAM (teamName, teamCaptain, abbreviation) VALUES (:TEAMNAME, :TEAMCAPTAIN, :ABBREVIATION)";
         using (OracleCommand command = new OracleCommand(Insert, connection))
         {
             command.Parameters.Add(new OracleParameter("TEAMNAME", team.TeamName));
             command.Parameters.Add(new OracleParameter("TEAMCAPTAIN", team.TeamCaptain.LoginName));
             command.Parameters.Add(new OracleParameter("ABBREVIATION", team.Abbreviation));
             command.ExecuteNonQuery();
         }
     }
 }
Ejemplo n.º 3
0
        private void LoadTeam()
        {
            string teamName = Request.QueryString["teamName"];

            foreach (RankedTeam t in admin.Teams)
            {
                if (t.TeamName == teamName)
                {
                    team = t;
                }
            }
            if (team != null)
            {
                TeamName.InnerText = team.ToString();
                this.Title         = team.ToString();
            }
        }
Ejemplo n.º 4
0
        private Match CreateMatchFromReader(OracleDataReader reader, List <RankedTeam> teams)
        {
            int        matchID        = Convert.ToInt32(reader["matchID"]);
            string     blueTeamName   = Convert.ToString(reader["blueTeam"]);
            string     purpleTeamName = Convert.ToString(reader["purpleTeam"]);
            RankedTeam blueTeam       = null;
            RankedTeam purpleTeam     = null;

            foreach (RankedTeam r in teams)
            {
                if (r.TeamName == blueTeamName)
                {
                    blueTeam = r;
                }
                else if (r.TeamName == purpleTeamName)
                {
                    purpleTeam = r;
                }
                if (blueTeam != null && purpleTeam != null)
                {
                    break;
                }
            }
            DateTime   startTime           = Convert.ToDateTime(reader["StartTime"]);
            string     matchDurationString = Convert.ToString(reader["matchDuration"]);
            int        indexOfColon        = matchDurationString.IndexOf(":");
            int        indexOfSecondColon  = matchDurationString.IndexOf(":", 4);
            int        matchHours          = Convert.ToInt32(matchDurationString.Substring(0, indexOfColon));
            int        matchMinutes        = Convert.ToInt32(matchDurationString.Substring(indexOfColon + 1, 2));
            int        matchSeconds        = Convert.ToInt32(matchDurationString.Substring(indexOfSecondColon + 1));
            TimeSpan   matchDuration       = new TimeSpan(matchHours, matchMinutes, matchSeconds);
            string     victorName          = Convert.ToString(reader["victor"]);
            RankedTeam victor = null;

            if (blueTeam.TeamName == victorName)
            {
                victor = blueTeam;
            }
            else if (purpleTeam.TeamName == victorName)
            {
                victor = purpleTeam;
            }
            return(new Match(matchID, blueTeam, purpleTeam, startTime, matchDuration, victor));
        }
        private List <RankedTeam> CalucalteRankedTeams(List <Match> matches, List <SeasonToTeamRelation> seasonToTeamRelations)
        {
            var result = new List <RankedTeam>();

            foreach (var team in seasonToTeamRelations)
            {
                var rankedTeam = new RankedTeam {
                    Team = team.Team
                };
                foreach (var match in matches)
                {
                    if (match.HomeTeam.Equals(team.Team))
                    {
                        rankedTeam.NumberOfMatches += 1;
                        if (match.HomeTeamScore > match.AwayTeamScore)
                        {
                            rankedTeam.NumberOfWins += 1;
                            rankedTeam.Score        += 3;
                            var goalDifference = match.HomeTeamScore - match.AwayTeamScore;
                            rankedTeam.GoalDifference += goalDifference;
                        }
                        else if (match.HomeTeamScore == match.AwayTeamScore)
                        {
                            rankedTeam.NumberOfTieds += 1;
                            rankedTeam.Score         += 1;
                            // no goal difference need, because it's zero.
                        }
                        else
                        {
                            rankedTeam.NumberOfLooses += 1;
                            var goalDifference = match.HomeTeamScore - match.AwayTeamScore;
                            rankedTeam.GoalDifference += goalDifference;
                        }
                    }
                    else if (match.AwayTeam.Equals(team.Team))
                    {
                        rankedTeam.NumberOfMatches += 1;
                        if (match.AwayTeamScore > match.HomeTeamScore)
                        {
                            rankedTeam.NumberOfWins += 1;
                            rankedTeam.Score        += 3;
                            var goalDifference = match.AwayTeamScore - match.HomeTeamScore;
                            rankedTeam.GoalDifference += goalDifference;
                        }
                        else if (match.HomeTeamScore == match.AwayTeamScore)
                        {
                            rankedTeam.NumberOfTieds += 1;
                            rankedTeam.Score         += 1;
                        }
                        else
                        {
                            rankedTeam.NumberOfLooses += 1;
                            var goalDifference = match.AwayTeamScore - match.HomeTeamScore;
                            rankedTeam.GoalDifference += goalDifference;
                        }
                    }
                }
                result.Add(rankedTeam);
            }
            return(result);
        }