예제 #1
0
 public JsonResult AddTeam(NewTeam model)
 {
     TeamRepository tRepo = new TeamRepository();
     //LeagueID is hardcoded to the default one
     int teamId = tRepo.AddTeam(new Team() { LeagueId = 0, TeamName = model.NewTeamName, Manager = model.NewManagerName });
     return Json(new { Success = true, Message = model.NewTeamName, Id = teamId });
 }
예제 #2
0
 public void RunLoadTeams()
 {
     var numTeamsInDatabase = 5;
     var repo = new TeamRepository();
     var teams = repo.LoadTeams();
     Assert.AreEqual(numTeamsInDatabase, teams.Count);
 }
예제 #3
0
 public void RunLoadTeamsById()
 {
     var teamIdToLoad = 1;
     var teamNameToTest = "Cleveland Indians";
     var repo = new TeamRepository();
     var team = repo.LoadTeamById(teamIdToLoad);
     Assert.AreEqual(teamNameToTest,team.TeamName);
 }
예제 #4
0
        public TeamList GetTeamList()
        {
            TeamList model = new TeamList();
            TeamRepository tRepo = new TeamRepository();
            PlayersRepository pRepo = new PlayersRepository();
            model.Teams = tRepo.LoadTeams();
            List<Player> players = pRepo.LoadPlayers();
            foreach (Team team in model.Teams)
                team.Players = players.Where(p => p.TeamId == team.TeamId).ToList();

            return model;
        }