Example #1
0
 private static void DeleteSloganQuestionCache(AspNetDating.Classes.User.eGender gender)
 {
     string cacheKey = String.Format("ProfileQuestion_SloganQuestionID_{0}", gender.ToString());
     if (HttpContext.Current.Cache[cacheKey] != null)
         HttpContext.Current.Cache.Remove(cacheKey);
 }
Example #2
0
        public static int? GetSloganQuestionIDByGender(AspNetDating.Classes.User.eGender gender)
        {
            string cacheKey = String.Format("ProfileQuestion_SloganQuestionID_{0}", gender.ToString());
            if (HttpContext.Current != null && HttpContext.Current.Cache[cacheKey] != null)
            {
                return (int) HttpContext.Current.Cache[cacheKey];
            }

            foreach (var question in Fetch())
            {
                if (question.ShowStyle == eShowStyle.Slogan)
                {
                    if (
                        (gender == User.eGender.Male && !question.VisibleForMale) ||
                        (gender == User.eGender.Female && !question.VisibleForFemale) ||
                        (gender == User.eGender.Couple && !question.VisibleForCouple)
                        )
                        continue;

                    if (HttpContext.Current != null)
                    {
                        HttpContext.Current.Cache.Insert(cacheKey, question.Id, null, Cache.NoAbsoluteExpiration,
                                                         TimeSpan.FromHours(1), CacheItemPriority.NotRemovable, null);
                    }

                    return question.Id;
                }
            }

            return null;
        }