public bool UpdateSport(Sport sport) { var sportDto = new SportDto(); sportDto = convert.ToSportDto(sport); var model = new bool(); using (var client = new ToteService.BetListServiceClient()) { try { client.Open(); model = client.UpdateSport(sportDto); client.Close(); } catch (FaultException <CustomException> customEx) { log.Error(customEx.Message); return(false); } catch (CommunicationException commEx) { log.Error(commEx.Message); return(false); } } return(model); }
public SportDto GetSport(int?id) { var model = new SportDto(); using (var client = new ToteService.BetListServiceClient()) { try { client.Open(); model = client.GetSport(id); 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); }
public bool AddBet(Bet bet, int basketId) { var betDto = new BetDto(); betDto = convert.ToBetDto(bet); var model = new bool(); using (var client = new ToteService.BetListServiceClient()) { try { client.Open(); model = client.AddBet(betDto, basketId); client.Close(); } catch (FaultException <CustomException> customEx) { log.Error(customEx.Message); return(false); } catch (CommunicationException commEx) { log.Error(commEx.Message); return(false); } } return(model); }
public bool DeleteSport(int sportId) { var model = new bool(); using (var client = new ToteService.BetListServiceClient()) { try { client.Open(); model = client.DeleteSport(sportId); client.Close(); } catch (FaultException <CustomException> customEx) { log.Error(customEx.Message); return(false); } catch (CommunicationException commEx) { log.Error(commEx.Message); return(false); } } return(model); }
public IReadOnlyList <BetListDto> GetBetsAll() { var model = new List <BetListDto>(); using (var client = new ToteService.BetListServiceClient()) { try { client.Open(); var bets = client.GetBetsAll(); foreach (var bet in bets) { model.Add(bet); } 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); }
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); }
public int AddRate(Rate rate) { var rateDto = new RateDto(); rateDto = convert.ToRateDto(rate); var model = new int(); using (var client = new ToteService.BetListServiceClient()) { try { client.Open(); model = client.GetRateIdAfterAdd(rateDto); if (model <= 0) { throw new ArgumentOutOfRangeException("Not positive number not allowed"); } client.Close(); } catch (FaultException <CustomException> customEx) { log.Error(customEx.Message); return(0); } catch (CommunicationException commEx) { log.Error(commEx.Message); return(0); } catch (ArgumentOutOfRangeException argEx) { log.Error(argEx.Message); return(0); } } return(model); }