Example #1
0
        public static void AddMatchDetailsToDb(sakilaEntities4 db, int homeTeamID, int awayTeamID, int homeTeamGoals, int awayTeamGoals, DateTime matchDate, int competitionMatchID)
        {
            var newMatch = new competitionmatch();

            newMatch.HomeTeamID   = homeTeamID;
            newMatch.AwayTeamID   = awayTeamID;
            newMatch.HomeGoals    = homeTeamGoals;
            newMatch.AwayGoals    = awayTeamGoals;
            newMatch.WinnerTeamID = Helper.GetWinnerTeamID(homeTeamID, homeTeamGoals, awayTeamID,
                                                           awayTeamGoals);
            newMatch.MatchDate     = matchDate;
            newMatch.CompetitionID = competitionMatchID;

            db.competitionmatch.Add(newMatch);
            db.SaveChanges();
        }
Example #2
0
        public static void AddMatchDetailsToDb(DataObjects.MatchDetails match, sakilaEntities4 db, int homeTeamID, int awayTeamID, int competitionID = 10)
        {
            var newMatch = new competitionmatch();

            newMatch.HomeTeamID   = homeTeamID;
            newMatch.AwayTeamID   = awayTeamID;
            newMatch.HomeGoals    = match.HomeTeam.Goals;
            newMatch.AwayGoals    = match.AwayTeam.Goals;
            newMatch.WinnerTeamID = Helper.GetWinnerTeamID(homeTeamID, match.HomeTeam.Goals, awayTeamID,
                                                           match.AwayTeam.Goals);
            newMatch.MatchDate     = match.Date;
            newMatch.CompetitionID = competitionID;

            db.competitionmatch.Add(newMatch);
            db.SaveChanges();
            match.MatchID = newMatch.CompetitionMatchID;
        }
        public static string GetCompetitionMatchResultLetter(competitionmatch match, int teamId)
        {
            var latest = "";

            if (match.WinnerTeamID == teamId)
            {
                latest = "W";
            }

            else if (match.WinnerTeamID == null)
            {
                latest = "D";
            }

            else
            {
                latest = "L";
            }

            return(latest);
        }
Example #4
0
        public static AttributesMatch GetAttributeMatch(sakilaEntities4 db, competitionmatch match)
        {
            var attributesDict     = SecondaryStatsCalculator.BuildAttributesDictionary(match.CompetitionID, db, 50, match.MatchDate);
            var homeTeamAttributes = Helper.GetTeamAttributeFromDict((int)match.HomeTeamID, attributesDict);
            var awayTeamAttributes = Helper.GetTeamAttributeFromDict((int)match.AwayTeamID, attributesDict);
            List <DataObjects.AttributeType> winnerAttributes = null;

            if (match.WinnerTeamID == match.HomeTeamID)
            {
                winnerAttributes = homeTeamAttributes;
            }
            else if (match.WinnerTeamID == match.AwayTeamID)
            {
                winnerAttributes = awayTeamAttributes;
            }

            return(new AttributesMatch
            {
                HomeAttributes = homeTeamAttributes,
                AwayAttributes = awayTeamAttributes,
                WinnerAttributes = winnerAttributes
            });
        }
Example #5
0
        public static MatchStrengthDetails GetMatchStrengthDetails(sakilaEntities4 db, competitionmatch match, int competitionId)
        {
            var homeTeamStrength = CalculateTeamStrength(db, match.HomeTeamID, "Home", competitionId, match.MatchDate);
            var awayTeamStrength = CalculateTeamStrength(db, match.AwayTeamID, "Away", competitionId, match.MatchDate);
            var winner           = "Draw";

            if (match.WinnerTeamID == match.HomeTeamID)
            {
                winner = "Home";
            }

            if (match.WinnerTeamID == match.AwayTeamID)
            {
                winner = "Away";
            }

            return(new MatchStrengthDetails
            {
                HomeTeamStrength = homeTeamStrength,
                AwayTeamStength = awayTeamStrength,
                Winner = winner
            });
        }