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 }); }
public void RunLoadTeams() { var numTeamsInDatabase = 5; var repo = new TeamRepository(); var teams = repo.LoadTeams(); Assert.AreEqual(numTeamsInDatabase, teams.Count); }
public void RunLoadTeamsById() { var teamIdToLoad = 1; var teamNameToTest = "Cleveland Indians"; var repo = new TeamRepository(); var team = repo.LoadTeamById(teamIdToLoad); Assert.AreEqual(teamNameToTest,team.TeamName); }
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; }