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); }