Example #1
0
        public bool DeleteTournament(int tournamentId)
        {
            var model = new bool();

            using (var client = new ToteService.TournamentServiceClient())
            {
                try
                {
                    client.Open();
                    model = client.DeleteTournament(tournamentId);
                    client.Close();
                }

                catch (FaultException <CustomException> customEx)
                {
                    log.Error(customEx.Message);
                    return(false);
                }
                catch (CommunicationException commEx)
                {
                    log.Error(commEx.Message);
                    return(false);
                }
            }
            return(model);
        }
Example #2
0
        public TournamentDto GetTournamentById(int tournamentId)
        {
            var model = new TournamentDto();

            using (var client = new ToteService.TournamentServiceClient())
            {
                try
                {
                    client.Open();
                    model = client.GetTournamentById(tournamentId);
                    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);
        }
Example #3
0
        public bool AddTournament(Tournament tournament)
        {
            var tournamentDto = new TournamentDto();

            tournamentDto = convert.ToTournamentDto(tournament);
            var model = new bool();

            using (var client = new ToteService.TournamentServiceClient())
            {
                try
                {
                    client.Open();
                    model = client.AddTournament(tournamentDto);
                    client.Close();
                }

                catch (FaultException <CustomException> customEx)
                {
                    log.Error(customEx.Message);
                    return(false);
                }
                catch (CommunicationException commEx)
                {
                    log.Error(commEx.Message);
                    return(false);
                }
            }
            return(model);
        }
Example #4
0
        public IReadOnlyList <TournamentDto> GetTournamentes()
        {
            var model = new List <TournamentDto>();

            using (var client = new ToteService.TournamentServiceClient())
            {
                try
                {
                    client.Open();

                    var tournaments = client.GetTournamentes();
                    foreach (var tournament in tournaments)
                    {
                        model.Add(tournament);
                    }
                    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);
        }