Beispiel #1
0
        public void AddTeamTest()
        {
            var teamToAdd = new Team()
            {
                Name = "Dallas Cowboys",
                Manager = "Ryan Rowe",
                LeagueId = 0,
                Players = new List<Player>
                {
                    new Player
                    {
                        Id = 10,
                        FirstName = "Jason",
                        LastName = "Bekkel",
                        BattingAvg = .235,
                        JerseyNumber = 17,
                        Position = Positions.C,
                        YearsPlayed = 6,
                        TeamId = 2
                    },
                    new Player
                    {
                        Id = 11,
                        FirstName = "Randal",
                        LastName = "Randelic",
                        BattingAvg = .382,
                        JerseyNumber = 52,
                        Position = Positions.TB,
                        YearsPlayed = 10,
                        TeamId = 2
                    },
                    new Player
                    {
                        Id = 12,
                        FirstName = "Dak",
                        LastName = "Prescott",
                        BattingAvg = .275,
                        JerseyNumber = 33,
                        Position = Positions.CF,
                        YearsPlayed = 9,
                        TeamId = 2,
                    }

                }
            };

            manager.AddTeam(teamToAdd);

            var _teams = manager.GetAllTeams();

            foreach (var t in _teams)
            {
                Console.WriteLine($"{t.Id}, {t.Name}, {t.Manager}");

                foreach (var p in t.Players)
                {
                    Console.WriteLine($"{p.Id}, {p.FirstName}, {p.LastName}");
                }
            }
        }
 public void EditTeam(Team team)
 {
     var selectedTeam = _teams.FirstOrDefault(t => t.Id == team.Id);
     selectedTeam.Id = team.Id;
     selectedTeam.Name = team.Name;
        // selectedTeam.LeagueId = team.LeagueId;
     selectedTeam.Manager = team.Manager;
        // selectedTeam.Players = team.Players;
 }
Beispiel #3
0
 public void AddTeam(Team team)
 {
     if (GetAllTeams().Count == 0)
     {
         team.Id = 1;
     }
     else
     {
         team.Id = GetAllTeams().LastOrDefault().Id + 1;
     }
     team.Players = new List<Player>();
     _teamrepo.AddTeam(team);
 }
Beispiel #4
0
 public ActionResult Create(FormCollection collection)
 {
     Team team = new Team();
     try
     {
         UpdateModel(team, new string[] {"TeamName" });
         _teamRepository.Create(team);
         _teamRepository.Save();
         return RedirectToAction("Edit", new { id = team.TeamID });
     }
     catch
     {
         //ModelState.AddRuleViolations(dinner.GetRuleViolations());
         return View(team);
     }
 }
 public void AddTeam(Team team)
 {
     _teams.Add(team);
     WriteFile();
 }
Beispiel #6
0
        public ActionResult EditTeam(Team team)
        {
            if (ModelState.IsValid)
            {
                var manager = new TeamManager();
                manager.EditTeam(team);

                return RedirectToAction("Teams");
            }
            return View();
        }
Beispiel #7
0
        public ActionResult DeleteTeam(Team team)
        {
            var manager = new TeamManager();
            manager.DeleteTeam(team.Id);

            return RedirectToAction("Teams");
        }
Beispiel #8
0
 public void EditTeam(Team team)
 {
     _teamrepo.EditTeam(team);
 }
Beispiel #9
0
 public void TradePlayers(Team team1, Team team2, Player player1, Player player2)
 {
     int x =  player1.TeamId;
     player1.TeamId = player2.TeamId;
     player2.TeamId = x;
     team1.Players.Remove(player1);
     team2.Players.Remove(player2);
     team1.Players.Add(player2);
     team2.Players.Add(player1);
 }
 public void EditTeam(Team team)
 {
     var selectedTeam = _teams.FirstOrDefault(t => t.Id == team.Id);
     selectedTeam.Name = team.Name;
     //selectedTeam.LeagueId = team.LeagueId; taking this and Players below out seemed to work and changed the controller and they keep they re old props
     selectedTeam.Manager = team.Manager;
        // selectedTeam.Players = team.Players;
 }
 public void AddTeam(Team team)
 {
     _teams.Add(team);
 }