public bool DeleteCountry(int countryId) { var model = new bool(); using (var client = new TeamService.TeamServiceClient()) { try { client.Open(); model = client.DeleteCountry(countryId); client.Close(); } catch (FaultException <CustomException> customEx) { log.Error(customEx.Message); return(false); } catch (CommunicationException commEx) { log.Error(commEx.Message); return(false); } } return(model); }
public bool AddTeam(Team team) { var teamDto = new TeamDto(); teamDto = convert.ToTeamDto(team); var model = new bool(); using (var client = new TeamService.TeamServiceClient()) { try { client.Open(); model = client.AddTeam(teamDto); client.Close(); } catch (FaultException <CustomException> customEx) { log.Error(customEx.Message); return(false); } catch (CommunicationException commEx) { log.Error(commEx.Message); return(false); } } return(model); }
public bool UpdateCountry(Country country) { var countryDto = new CountryDto(); countryDto = convert.ToCountryDto(country); var model = new bool(); using (var client = new TeamService.TeamServiceClient()) { try { client.Open(); model = client.UpdateCountry(countryDto); client.Close(); } catch (FaultException <CustomException> customEx) { log.Error(customEx.Message); return(false); } catch (CommunicationException commEx) { log.Error(commEx.Message); return(false); } } return(model); }
public TeamDto GetTeamById(int teamId) { var model = new TeamDto(); using (var client = new TeamService.TeamServiceClient()) { try { client.Open(); model = client.GetTeamById(teamId); client.Close(); if (model == null) { throw new NullReferenceException(); } } catch (FaultException <CustomException> customEx) { log.Error(customEx.Message); return(null); } catch (CommunicationException commEx) { log.Error(commEx.Message); return(null); } catch (NullReferenceException nullEx) { log.Error(nullEx.Message); return(null); } } return(model); }
public IReadOnlyList <TeamDto> GetTeamsByTournament(int tournamentId) { var model = new List <TeamDto>(); using (var client = new TeamService.TeamServiceClient()) { try { client.Open(); var teams = client.GetTeamsByTournament(tournamentId); foreach (var team in teams) { model.Add(team); } client.Close(); if (model == null) { throw new NullReferenceException(); } } catch (FaultException <CustomException> customEx) { log.Error(customEx.Message); return(null); } catch (CommunicationException commEx) { log.Error(commEx.Message); return(null); } catch (NullReferenceException nullEx) { log.Error(nullEx.Message); return(null); } } return(model); }
public IReadOnlyList <CountryDto> GetCountriesAll() { var model = new List <CountryDto>(); using (var client = new TeamService.TeamServiceClient()) { try { client.Open(); var countries = client.GetCountriesAll(); foreach (var country in countries) { model.Add(country); } client.Close(); if (model == null) { throw new NullReferenceException(); } } catch (FaultException <CustomException> customEx) { log.Error(customEx.Message); return(null); } catch (CommunicationException commEx) { log.Error(commEx.Message); return(null); } catch (NullReferenceException nullEx) { log.Error(nullEx.Message); return(null); } } return(model); }