Example #1
0
        public IReadOnlyList <EventDto> GetEvents(int id)
        {
            var model = new List <EventDto>();

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

                    var events = client.GetEvents(id);
                    foreach (var _event in events)
                    {
                        model.Add(_event);
                    }
                    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);
        }