public async Task <IHttpActionResult> Get(string clubReference) { bool converts = int.TryParse(clubReference, out int clubId); if (converts == false) { return(BadRequest()); } DatabaseAccess.ExternalModel.Club databaseClub = await _clubRepository.GetClubAsync(clubId); if (databaseClub == null) { return(NotFound()); } Club newClub = new Club(); newClub.ClubId = databaseClub.ClubId; newClub.ShortName = databaseClub.ShortName; newClub.LongName = databaseClub.LongName; newClub.Description = databaseClub.Description; newClub.Url = databaseClub.Url; newClub.ContactName = databaseClub.ContactName; newClub.AddressLine1 = databaseClub.AddressLine1; newClub.AddressLine2 = databaseClub.AddressLine2; newClub.AddressLine3 = databaseClub.AddressLine3; newClub.Postcode = databaseClub.Postcode; newClub.Telephone = databaseClub.Telephone; newClub.Fax = databaseClub.Fax; newClub.Link = Url.Content("~/") + "club/" + newClub.ClubId; newClub.TeamsLink = Url.Content("~/") + "club/" + newClub.ClubId + "/teams"; return(Ok(newClub)); }
public async Task <IHttpActionResult> GetTeamsInClub(string clubReference) { bool converts = int.TryParse(clubReference, out int clubId); if (converts == false) { return(BadRequest()); } DatabaseAccess.ExternalModel.Club databaseClub = await _clubRepository.GetClubAsync(clubId); if (databaseClub == null) { return(NotFound()); } ReadOnlyCollection <TeamsInClubResult> databaseTeams = await _teamRepository.GetTeamsInClubAsync(clubId); Club club = new Club(); club.ClubId = databaseClub.ClubId; club.ShortName = databaseClub.ShortName; club.Link = Url.Content("~/") + "club/" + club.ClubId; List <Models.Team> newTeams = new List <Models.Team>(); foreach (TeamsInClubResult team in databaseTeams) { Models.Team newTeam = new Models.Team(); newTeam.TeamId = team.TeamId; newTeam.ShortName = team.TeamName; newTeam.NclTeam = team.NclTeam; newTeam.LongName = team.LongName; newTeam.Link = Url.Content("~/") + "team/" + newTeam.TeamId; newTeams.Add(newTeam); } club.Teams = newTeams; return(Ok(club)); }