コード例 #1
0
ファイル: TeamTesting.cs プロジェクト: alexgrbach/Projects
        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}");
                }
            }
        }
コード例 #2
0
 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;
 }
コード例 #3
0
ファイル: TeamManager.cs プロジェクト: alexgrbach/Projects
 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);
 }
コード例 #4
0
ファイル: TeamsController.cs プロジェクト: veritas27/Baseball
 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);
     }
 }
コード例 #5
0
 public void AddTeam(Team team)
 {
     _teams.Add(team);
     WriteFile();
 }
コード例 #6
0
        public ActionResult EditTeam(Team team)
        {
            if (ModelState.IsValid)
            {
                var manager = new TeamManager();
                manager.EditTeam(team);

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

            return RedirectToAction("Teams");
        }
コード例 #8
0
ファイル: TeamManager.cs プロジェクト: alexgrbach/Projects
 public void EditTeam(Team team)
 {
     _teamrepo.EditTeam(team);
 }
コード例 #9
0
ファイル: TeamManager.cs プロジェクト: alexgrbach/Projects
 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);
 }
コード例 #10
0
 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;
 }
コード例 #11
0
 public void AddTeam(Team team)
 {
     _teams.Add(team);
 }