public decimal GetPrice(Delivery delivery, string currencyCode) { var requestObject = new EstimatePriceRequestFactory().Create(delivery, ProviderApiKey, delivery.ShippingOption.ShippingOptionCarrierServiceName); var requestString = microserviceClient.GetRequestString(requestObject); string cacheKey = $"estimatedeliveryprice|{ServiceUrl}|{requestString}"; var result = CacheHelper.Cache(() => CallEstimationService(requestObject), new CacheSettings(5, cacheKey)); return(result.Success ? (decimal)result.Payload?.Cost : 0.0m); }
public bool CanDeliver(Delivery delivery) { if (delivery.Items.Count() == 0 || delivery.DeliveryAddress == null) { return(false); } var requestObject = new EstimatePriceRequestFactory().Create(delivery, ProviderApiKey, delivery.ShippingOption.ShippingOptionCarrierServiceName); var requestString = microserviceClient.GetRequestString(requestObject); string cacheKey = $"estimatedeliveryprice|{ServiceUrl}|{requestString}"; var result = CacheHelper.Cache(() => CallEstimationService(requestObject), new CacheSettings(5, cacheKey)); return(result.Success); }