Exemplo n.º 1
0
        //public static decimal GetProductStepPrice(this int productSysNo, decimal oldPrice, int productCount = 1)
        //{
        //    List<ProductStepPrice> productStepPrices = null;
        //    string cacheKey = "GetProductStepPrice_" + productSysNo;
        //    if (HttpRuntime.Cache[cacheKey] != null)
        //    {
        //        productStepPrices = (List<ProductStepPrice>)HttpRuntime.Cache[cacheKey];
        //    }
        //    else
        //    {
        //        productStepPrices = CommonDA.GetProductStepPrice(productSysNo);
        //        HttpRuntime.Cache.Insert(cacheKey, productStepPrices, null, DateTime.Now.AddSeconds(CacheTime.Longest), Cache.NoSlidingExpiration);
        //    }

        //    if (productStepPrices == null)
        //    {
        //        return oldPrice;
        //    }
        //    ProductStepPrice productStepPrice = productStepPrices.FirstOrDefault(c => (c.BaseCount >= productCount && productCount <= c.TopCount));
        //    if (productStepPrice == null)
        //    {
        //        return oldPrice;
        //    }
        //    return productStepPrice.StepPrice;
        //}

        public static decimal GetProductStepPrice(this decimal oldPrice, int productSysNo, int productCount = 1)
        {
            List <ProductStepPrice> productStepPrices = null;
            string cacheKey = "GetProductStepPrice_" + productSysNo;

            if (HttpRuntime.Cache[cacheKey] != null)
            {
                productStepPrices = (List <ProductStepPrice>)HttpRuntime.Cache[cacheKey];
            }
            else
            {
                productStepPrices = CommonDA.GetProductStepPrice(productSysNo);
                HttpRuntime.Cache.Insert(cacheKey, productStepPrices, null, DateTime.Now.AddSeconds(CacheTime.Longest), Cache.NoSlidingExpiration);
            }

            if (productStepPrices == null)
            {
                return(oldPrice);
            }
            ProductStepPrice productStepPrice = productStepPrices.FirstOrDefault(c => (c.BaseCount <= productCount && productCount <= c.TopCount));

            if (productStepPrice == null)
            {
                return(productStepPrices.FirstOrDefault(c => (c.BaseCount == 0 && 0 == c.TopCount)).StepPrice);
            }
            return(productStepPrice.StepPrice);
        }
Exemplo n.º 2
0
        private static decimal GetProductStepPrice(decimal oldPrice, int productSysNo, int productCount)
        {
            List <ProductStepPrice> productStepPrices = null;

            productStepPrices = CommonDA.GetProductStepPrice(productSysNo);


            if (productStepPrices == null)
            {
                return(oldPrice);
            }
            ProductStepPrice productStepPrice = productStepPrices.FirstOrDefault(c => (c.BaseCount <= productCount && productCount <= c.TopCount));

            if (productStepPrice == null)
            {
                return(productStepPrices.FirstOrDefault(c => (c.BaseCount == 0 && 0 == c.TopCount)).StepPrice);
            }
            return(productStepPrice.StepPrice);
        }