public IActionResult DeleteTeam(int id)
        {
            try
            {
                var teamservice = _logicFactory.GetTeamService();
                //delete the team
                teamservice.Remove(new Team {
                    TeamID = id
                });
                //get all the teams that remain to update the view
                var allTeams = teamservice.GetAll();
                AdminManageTeamListView model = new AdminManageTeamListView();
                model.TeamList = new List <TeamListView>();
                foreach (Team team in allTeams)
                {
                    model.TeamList.Add(new TeamListView
                    {
                        Teamname        = team.TeamName,
                        TeamcaptainName = team.TeamCaptain?.PlayerName,
                        TeamID          = team.TeamID
                    });
                }

                return(PartialView("Team/_ManageTeamListPartial", model));
            }
            catch (Exception ex)
            {
                _logger.LogError($"Something went wrong trying to delete a team to the database. |Message: {ex.Message} |Stacktrace: {ex.StackTrace}");
                //notfound will result in a ajax error result. this will show a message to the user.
                //could also return a partial view with a script that runs to show the messagebox. this feels cleaner.
                //i couldn't find a way to send a Json result with partial view and success yes or no
                return(NotFound());
            }
        }
 public IActionResult ManageTeam()
 {
     try
     {
         var teamservice = _logicFactory.GetTeamService();
         var allTeams    = teamservice.GetAll();
         AdminManageTeamListView model = new AdminManageTeamListView();
         model.TeamList = new List <TeamListView>();
         foreach (Team team in allTeams)
         {
             model.TeamList.Add(new TeamListView
             {
                 Teamname        = team.TeamName,
                 TeamcaptainName = team.TeamCaptain?.PlayerName,
                 TeamID          = team.TeamID
             });
         }
         return(PartialView("Team/_ManageTeamListPartial", model));
     }
     catch (Exception ex)
     {
         _logger.LogError($"Something went wrong trying to get all teams for the manage modal. |Message: {ex.Message} |Stacktrace: {ex.StackTrace}");
         //notfound will result in a ajax error result. this will show a message to the user.
         return(NotFound());
     }
 }