Example #1
0
        /// <summary>
        /// The save.
        /// </summary>
        /// <param name="gatewayProviderService">
        /// The gateway provider service.
        /// </param>
        /// <param name="cache">
        /// The cache.
        /// </param>
        /// <param name="rateTable">
        /// The rate table.
        /// </param>
        internal static void Save(IGatewayProviderService gatewayProviderService, IRuntimeCacheProvider cache, IShippingFixedRateTable rateTable)
        {
            // clear the current cached item
            // TODO : This should use the distributed cache referesher
            cache.ClearCacheItem(CacheKeys.GatewayShipMethodCacheKey(rateTable.ShipMethodKey));

            // persist and enter into cache
            gatewayProviderService.Save(rateTable.Rows);
            cache.GetCacheItem(CacheKeys.GatewayShipMethodCacheKey(rateTable.ShipMethodKey), () => rateTable, TimeSpan.FromHours(6));
        }
Example #2
0
 /// <summary>
 /// The get ship rate table.
 /// </summary>
 /// <param name="gatewayProviderService">
 /// The gateway provider service.
 /// </param>
 /// <param name="runtimeCacheProvider">
 /// The runtime cache provider.
 /// </param>
 /// <param name="shipMethodKey">
 /// The ship method key.
 /// </param>
 /// <returns>
 /// The <see cref="ShippingFixedRateTable"/>.
 /// </returns>
 internal static ShippingFixedRateTable GetShipRateTable(IGatewayProviderService gatewayProviderService, IRuntimeCacheProvider runtimeCacheProvider, Guid shipMethodKey)
 {
     return((ShippingFixedRateTable)runtimeCacheProvider.GetCacheItem(
                CacheKeys.GatewayShipMethodCacheKey(shipMethodKey),
                delegate
     {
         var rows = gatewayProviderService.GetShipRateTiersByShipMethodKey(shipMethodKey);
         return new ShippingFixedRateTable(shipMethodKey, rows);
     }, TimeSpan.FromHours(6)));
 }
Example #3
0
        /// <summary>
        /// The delete row.
        /// </summary>
        /// <param name="gatewayProviderService">
        /// The gateway provider service.
        /// </param>
        /// <param name="cache">
        /// The cache.
        /// </param>
        /// <param name="rateTable">
        /// The rate table.
        /// </param>
        /// <param name="shipRateTier">
        /// The ship rate tier.
        /// </param>
        internal static void DeleteRow(IGatewayProviderService gatewayProviderService, IRuntimeCacheProvider cache, IShippingFixedRateTable rateTable, IShipRateTier shipRateTier)
        {
            var row = rateTable.Rows.FirstOrDefault(x => x.Key == shipRateTier.Key);

            if (!rateTable.Rows.Any() || row == null)
            {
                return;
            }

            if (rateTable.Rows.IndexOf(rateTable.Rows.Last()) != rateTable.Rows.IndexOf(row))
            {
                rateTable.Rows.First(x => x.RangeLow == row.RangeHigh).RangeLow = row.RangeLow;
            }

            // clear the current cached item
            // TODO : This should use the distributed cache referesher
            cache.ClearCacheItem(CacheKeys.GatewayShipMethodCacheKey(rateTable.ShipMethodKey));

            gatewayProviderService.Save(rateTable.Rows);
            gatewayProviderService.Delete(shipRateTier);

            cache.GetCacheItem(CacheKeys.GatewayShipMethodCacheKey(rateTable.ShipMethodKey), () => rateTable, TimeSpan.FromHours(6));
        }