Example #1
0
        public IReadOnlyList <RateDto> GetRateByUserId(int userId)
        {
            var model = new List <RateDto>();

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

                    var rates = client.GetRateByUserId(userId);
                    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);
        }