// GET: League/Details/5 public IActionResult Details(int?id) { if (id != null) { var league = _leagueRepository.GetLeagueById((int)id); if (league != null) { var leagueViewModel = new LeagueViewModel(); leagueViewModel.Id = league.Id; leagueViewModel.Name = league.Name; return(View(leagueViewModel)); } return(NotFound()); } return(BadRequest()); }