public ActionResult Index() { var dbContext = new TennisTrackerContext(); var singlesMatchRespotiory = new SinglesMatchRepository(dbContext); _singlesMatchRepository = singlesMatchRespotiory; var singlesMatches = _singlesMatchRepository.GetAllSinglesMatches(); return(View(singlesMatches)); }
public ActionResult Index() { var dbContext = new TennisTrackerContext(); _playerRepository = new PlayersRepository(dbContext); var players = _playerRepository.GetAllPlayers(); var singlesMatchRepository = new SinglesMatchRepository(dbContext); var singlesMatchService = new SinglesMatchService(singlesMatchRepository); var winLossDictionary = new List <Dictionary <int, string> >(); foreach (var player in players) { var winLoss = singlesMatchService.CalculateWinLoss(player.PlayerId); winLossDictionary.Add(winLoss); } var playersWithWinLoss = new PlayersWithWinLoss(players, winLossDictionary); return(View(playersWithWinLoss)); }