Example #1
0
        /// <summary>
        /// Push all promos from database into memory
        /// </summary>
        /// <param name="model"></param>
        public void UpdateCache(IEnumerable <PromoModel> model = null)
        {
            IEnumerable <PromoModel> promos = model ?? _repo.GetPromoModels();

            if (!promos.Any())
            {
                return;
            }

            foreach (PromoModel promo in promos)
            {
                string key = promo.ApplyTo == "this"
                    ? $"this_{promo.NodeId}"
                    : $"all_{promo.ContentTypeAlias}";

                HttpContext.Current.Cache[$"promotemodule_{key}_{promo.Guid}"] = promo;
            }
        }