Ejemplo n.º 1
0
        public ActionResult Index()
        {
            var dbContext = new TennisTrackerContext();
            var singlesMatchRespotiory = new SinglesMatchRepository(dbContext);

            _singlesMatchRepository = singlesMatchRespotiory;

            var singlesMatches =
                _singlesMatchRepository.GetAllSinglesMatches();

            return(View(singlesMatches));
        }
Ejemplo n.º 2
0
        public Dictionary <int, string> CalculateWinLoss(int playerId)
        {
            var singlesMatches =
                _singlesMatchRepository.GetAllSinglesMatches();

            var playersSinglesMatches =
                singlesMatches.Where(sm => sm.Player1Id == playerId || sm.Player2Id == playerId);

            var totalMatches = playersSinglesMatches.Count();

            var playerWins = playersSinglesMatches.Where(sm => sm.PlayerIdWinner == playerId).Count();

            var winLossString = string.Format("{0},{1}", totalMatches, playerWins);

            var winLoss = new Dictionary <int, string>();

            winLoss.Add(playerId, winLossString);

            return(winLoss);
        }