// // GET: /Player/ public ActionResult Index() { List <Team> sTeams = db.Teams.ToList(); List <Player> sPlayers = db.Players.ToList(); List <DisplayPlayer> sDisplayPlayer = new List <DisplayPlayer>(); ViewBag.Teams = sTeams; foreach (Player p in sPlayers) { DisplayPlayer player = new DisplayPlayer(); player.ID = p.ID; player.LastName = p.LastName; player.Sex = p.Sex; player.TeamID = p.TeamID; player.FirstName = p.FirstName; player.TeamName = sTeams.Find(o => o.ID == p.TeamID).Name; sDisplayPlayer.Add(player); } return(View(sDisplayPlayer)); }
// // GET: /Player/ public ActionResult Index() { List<Team> sTeams = db.Teams.ToList(); List<Player> sPlayers = db.Players.ToList(); List<DisplayPlayer> sDisplayPlayer = new List<DisplayPlayer>(); ViewBag.Teams = sTeams; foreach (Player p in sPlayers) { DisplayPlayer player = new DisplayPlayer(); player.ID = p.ID; player.LastName = p.LastName; player.Sex = p.Sex; player.TeamID = p.TeamID; player.FirstName = p.FirstName; player.TeamName = sTeams.Find(o => o.ID == p.TeamID).Name; sDisplayPlayer.Add(player); } return View(sDisplayPlayer); }