public ActionResult <IEnumerable <LeagueReadDto> > GetLeaguesByOrganisation(int organisationId) { try { string userId = User.Identity.Name; var leagues = _leagueService.GetLeaguesByOrganisation(organisationId); bool hasAccess = _leagueService.CheckLeagueAccess(int.Parse(userId), organisationId); if (!hasAccess) { return(Forbid()); } if (leagues == null) { return(NotFound()); } return(Ok(_mapper.Map <IEnumerable <LeagueReadDto> >(leagues))); } catch (Exception e) { return(StatusCode(500, e.Message)); } }