public BasketDto GetBasketById(int basketId, int userId) { var model = new BasketDto(); using (var client = new ToteService.BetListServiceClient()) { try { client.Open(); model = client.GetBasketById(basketId, userId); if (model == null) { throw new NullReferenceException(); } client.Close(); } 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); }