예제 #1
0
        public bool AddMatch(Match match)
        {
            var matchDto = new MatchDto();

            matchDto = convert.ToMatchDto(match);
            var model = new bool();

            using (var client = new TeamService.MatchServiceClient())
            {
                try
                {
                    client.Open();
                    model = client.AddMatch(matchDto);
                    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 MatchDto GetMatchById(int matchId)
        {
            var model = new MatchDto();

            using (var client = new TeamService.MatchServiceClient())
            {
                try
                {
                    client.Open();
                    model = client.GetMatchById(matchId);
                    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);
        }
예제 #3
0
        public bool DeleteMatch(int matchId)
        {
            var model = new bool();

            using (var client = new TeamService.MatchServiceClient())
            {
                try
                {
                    client.Open();
                    model = client.DeleteMatch(matchId);
                    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 IReadOnlyList <ResultDto> GetResultsAll()
        {
            var model = new List <ResultDto>();

            using (var client = new TeamService.MatchServiceClient())
            {
                try
                {
                    client.Open();
                    var results = client.GetResultsAll();
                    foreach (var result in results)
                    {
                        model.Add(result);
                    }
                    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 <SortDto> GetMatchBySportDateStatus(int sportId, string dateMatch, int status)
        {
            var model = new List <SortDto>();

            using (var client = new TeamService.MatchServiceClient())
            {
                try
                {
                    client.Open();
                    var matches = client.GetMatchBySportDateStatus(sportId, dateMatch, status);
                    foreach (var match in matches)
                    {
                        model.Add(match);
                    }
                    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);
        }