Ejemplo n.º 1
0
        public static List <SueetieBlog> GetSueetieBlogList(ApplicationQuery applicationQuery)
        {
            var provider = SueetieDataProvider.LoadProvider();

            var key = BlogListCacheKey(applicationQuery);

            var cachedSueetieBlogs = SueetieCache.Current[key] as List <SueetieBlog>;

            if (cachedSueetieBlogs != null)
            {
                if (applicationQuery.NumRecords > 0)
                {
                    return(cachedSueetieBlogs.Take(applicationQuery.NumRecords).ToList());
                }
                return(cachedSueetieBlogs.ToList());
            }

            var sueetieBlogs = from p in provider.GetSueetieBlogList(applicationQuery)
                               select p;

            if (applicationQuery.GroupID > -1)
            {
                sueetieBlogs = from g in sueetieBlogs where g.GroupID == applicationQuery.GroupID select g;
            }

            if (applicationQuery.CategoryID > 0)
            {
                sueetieBlogs = from a in sueetieBlogs where a.CategoryID == applicationQuery.CategoryID select a;
            }

            if (applicationQuery.IsRestricted)
            {
                sueetieBlogs = from r in sueetieBlogs where r.BlogAccessRole == null select r;
            }

            if (applicationQuery.CacheMinutes > 0)
            {
                SueetieCache.Current.InsertMinutes(key, sueetieBlogs.ToList(), applicationQuery.CacheMinutes);
            }
            else
            {
                SueetieCache.Current.InsertMax(key, sueetieBlogs.ToList());
            }


            if (applicationQuery.NumRecords > 0)
            {
                return(sueetieBlogs.Take(applicationQuery.NumRecords).ToList());
            }
            return(sueetieBlogs.ToList());
        }
Ejemplo n.º 2
0
 private static string BlogListCacheKey(ApplicationQuery applicationQuery)
 {
     return(string.Format("BlogList-{0}-{1}", SueetieConfiguration.Get().Core.SiteUniqueName, applicationQuery.CategoryID));
 }