Example #1
0
        public ActionResult AddFreeAgentToTeam(int id)
        {
            var teamManager = new TeamManager();
            var playerManager = new PlayerManager();
            var vm = new AddFreeAgentToTeamVM();
            vm.TeamToAddPlayer = teamManager.GetAllTeams().FirstOrDefault(t => t.Id == id);
            vm.TeamToRemovePlayer = teamManager.GetTeamById(0);
               // vm.TeamToRemovePlayer.Players = playerManager.GetAllPlayers().FindAll(p => p.TeamId == 0);
            vm.SetPlayerList(vm.TeamToRemovePlayer.Players);
            vm.SetTeamRoster(vm.TeamToAddPlayer.Players);

            return View(vm);
        }
Example #2
0
 public ActionResult AddLeaguelessTeamtoLeague(int id)
 {
     var teamManager = new TeamManager();
     var leagueManager = new LeagueManager();
     var vm = new AddNoLeagueTeamToLeagueVM();
     vm.LeagueToAddTeam = leagueManager.GetLeagueById(id);
     vm.LeagueToRemoveTeam = leagueManager.GetLeagueById(0);
     var teams1 = teamManager.GetAllTeams().FindAll(t => t.LeagueId == 0);
     teams1.RemoveAll(t => t.Id == 0);
     var teams2 = teamManager.GetAllTeams().FindAll(t => t.LeagueId == id);
     vm.SetLeaguelessTeams(teams1);
     vm.SetTeamsInLeague(teams2);
     return View(vm);
 }
Example #3
0
        public ActionResult AddFreeAgentToTeam(AddFreeAgentToTeamVM vm)
        {
            var teamManager = new TeamManager();
            var playerManager = new PlayerManager();
            var freeagency = teamManager.GetTeamById(0);
            var team = teamManager.GetAllTeams().FirstOrDefault(t => t.Id == vm.TeamToAddPlayer.Id);
            team.Players.Clear();

            if (vm.PlayersToAdd != null && vm.PlayersToAdd.Count > 0)
            {
                foreach (var playerid in vm.PlayersToAdd)
                {
                    freeagency.Players.RemoveAll(p => p.Id == playerid);
                    team.Players.Add(playerManager.GetPlayerById(playerid));
                    var player = playerManager.GetPlayerById(playerid);
                    player.TeamId = team.Id;
                }
            }

            return RedirectToAction("AddFreeAgentToTeam");
        }
Example #4
0
 public ActionResult ViewLeague(int id)
 {
     var leagueManager = new LeagueManager();
     var manager = new TeamManager();
     var league = leagueManager.GetLeagueById(id);
     var leagueVM = new LeagueVM();
     leagueVM.League = league;
     leagueVM.TeamsInLeague = manager.GetAllTeams().FindAll(t => t.LeagueId == leagueVM.League.Id);
     return View(leagueVM);
 }
Example #5
0
        public ActionResult Teams()
        {
            var manager = new TeamManager();
            var teams = manager.GetAllTeams();

            return View(teams);
        }
Example #6
0
 public ActionResult GetTeamsToTrade()
 {
     var teamManager = new TeamManager();
     var vm = new GetTeamsForTradeVM();
     var teams = teamManager.GetAllTeams().ToList();
     teams.RemoveAll(t => t.Players == null || t.Players.Count == 0);
     teams.RemoveAll(t => t.Id == 0);
     vm.SetTeam1List(teams);
     vm.SetTeam2List(teams);
     return View(vm);
 }
Example #7
0
        public ActionResult CutPlayerToFreeAgency(CutPlayerToFreeAgencyVM vm)
        {
            var teamManager = new TeamManager();
            var playerManager = new PlayerManager();
            var teamToRemovePlayer = teamManager.GetAllTeams().FirstOrDefault(t => t.Id == vm.TeamToRemovePlayer.Id);
            var team = teamManager.GetAllTeams().FirstOrDefault(t => t.Id == 0);
            team.Players.Clear();

            if (vm.PlayersToAdd != null && vm.PlayersToAdd.Count > 0)
            {
                foreach (var playerid in vm.PlayersToAdd)
                {
                    teamToRemovePlayer.Players.RemoveAll(p => p.Id == playerid);
                    team.Players.Add(playerManager.GetPlayerById(playerid));
                    var player = playerManager.GetPlayerById(playerid);
                    player.TeamId = team.Id;
                }
            }

            return RedirectToAction("CutPlayerToFreeAgency");
        }