Example #1
0
        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);
        }
Example #2
0
        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);
        }