public IReadOnlyList <BetDto> GetBetByRateId(int rateId) { var model = new List <BetDto>(); using (var client = new ToteService.BetListServiceClient()) { try { client.Open(); var rates = client.GetBetByRateId(rateId); foreach (var rate in rates) { model.Add(rate); } 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); }