public ActionResult Index(int?Id)
        {
            Id = Convert.ToInt32(TeamsRep.GetAllTeams().OrderBy(t => t.Id));

            var myplayers = PlayersRep.GetAllPlayers().Where(p => p.TeamId == Id);

            if (myplayers.Count() > 0)
            {
                ViewData["MyPlayers"] = myplayers.OrderBy(p => p.Team.Players);
            }
            return(View());
        }
        public ActionResult View(int Id)
        {
            PlayersRepository PlayerRep = new PlayersRepository();
            var myplayer = PlayerRep.GetAllPlayers().Where(r => r.Id == Id).FirstOrDefault();

            if (myplayer != null)
            {
                return(View(myplayer));
            }
            else
            {
                return(Redirect("/"));
            }
        }
Beispiel #3
0
        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));
        }