Ejemplo n.º 1
0
        /// <summary>
        /// 设置活动参数
        /// </summary>
        public void UpdateConfig(FlashSaleConfigModel data)
        {
            var model = DbFactory.Default.Get <FlashSaleConfigInfo>().FirstOrDefault();

            if (model == null)
            {
                model = new FlashSaleConfigInfo();
                model.IsNormalPurchase = data.IsNormalPurchase;
                model.Preheat          = data.Preheat;
                DbFactory.Default.Add(model);
            }
            else
            {
                model.IsNormalPurchase = data.IsNormalPurchase;
                model.Preheat          = data.Preheat;
                DbFactory.Default.Update(model);
            }
            string cacheKey = CacheKeyCollection.CACH_FLASHSALECONFIG;

            Cache.Remove(cacheKey);
        }
Ejemplo n.º 2
0
        public FlashSaleConfigModel GetConfig()
        {
            string cacheKey = CacheKeyCollection.CACH_FLASHSALECONFIG;

            if (Cache.Exists(cacheKey))
            {
                return(Cache.Get <FlashSaleConfigModel>(cacheKey));
            }

            var model = DbFactory.Default.Get <FlashSaleConfigInfo>().FirstOrDefault();

            if (model == null)
            {
                model = new FlashSaleConfigInfo();
                model.IsNormalPurchase = true;
                model.Preheat          = 24;
                DbFactory.Default.Add(model);
            }
            var result = new FlashSaleConfigModel(model.Preheat, model.IsNormalPurchase);

            Cache.Insert <FlashSaleConfigModel>(cacheKey, result, 600);
            return(result);
        }