Пример #1
0
        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);
        }
Пример #2
0
        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);
        }
Пример #3
0
        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);
        }
Пример #4
0
        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);
        }
Пример #5
0
        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);
        }
Пример #6
0
        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);
        }