public IReadOnlyList <BasketDto> GetBasketByUser(int userId) { var model = new List <BasketDto>(); using (var client = new ToteService.BetListServiceClient()) { try { client.Open(); var baskets = client.GetBasketByUser(userId); foreach (var basket in baskets) { model.Add(basket); } 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); }