public ActionResult DeleteLeagueById(int leagueId) { try { string userId = User.Identity.Name; LeagueModel league = _leagueService.GetLeagueById(leagueId); if (league == null) { return(NotFound()); } bool hasAccess = _leagueService.CheckLeagueAccess(int.Parse(userId), league.OrganisationId); if (!hasAccess) { return(Forbid()); } _leagueService.DeleteLeague(league); _leagueService.SaveChanges(); return(NoContent()); } catch (Exception e) { return(StatusCode(500, e.Message)); } }
public async Task <IActionResult> DeleteLeague(int leagueId) { var result = await _leagueService.DeleteLeague(leagueId); if (result.ErrorOccurred) { return(BadRequest(result)); } return(Ok(result)); }