Example #1
0
        public void SaveAttributeValues(int? personId)
        {
            Rock.Services.Cms.PageService pageService = new Services.Cms.PageService();
            Rock.Models.Cms.Page pageModel = pageService.GetPage( this.Id );
            if ( pageModel != null )
            {
                pageService.LoadAttributes( pageModel );

                foreach ( Rock.Models.Core.Attribute attribute in pageModel.Attributes )
                    pageService.SaveAttributeValue( pageModel, attribute, this.AttributeValues[attribute.Key].Value, personId );
            }
        }
Example #2
0
        /// <summary>
        /// Returns Page object from cache.  If page does not already exist in cache, it
        /// will be read and added to cache
        /// </summary>
        /// <param name="guid"></param>
        /// <returns></returns>
        public static Page Read( int id )
        {
            string cacheKey = Page.CacheKey( id );

            ObjectCache cache = MemoryCache.Default;
            Page page = cache[cacheKey] as Page;

            if ( page != null )
                return page;
            else
            {
                Rock.Services.Cms.PageService pageService = new Services.Cms.PageService();
                Rock.Models.Cms.Page pageModel = pageService.GetPage( id );
                if ( pageModel != null )
                {
                    pageService.LoadAttributes( pageModel );

                    page = Page.CopyModel( pageModel );

                    cache.Set( cacheKey, page, new CacheItemPolicy() );

                    return page;
                }
                else
                    return null;

            }
        }