Example #1
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="id"></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.CMS.PageService pageService = new CMS.PageService();
                Rock.CMS.Page        pageModel   = pageService.Get(id);
                if (pageModel != null)
                {
                    Rock.Attribute.Helper.LoadAttributes(pageModel);

                    page = Page.CopyModel(pageModel);

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

                    return(page);
                }
                else
                {
                    return(null);
                }
            }
        }
Example #2
0
 /// <summary>
 /// Saves the attribute values for the page
 /// </summary>
 /// <param name="personId">The person id.</param>
 public void SaveAttributeValues(int?personId)
 {
     Rock.CMS.PageService pageService = new CMS.PageService();
     Rock.CMS.Page        pageModel   = pageService.Get(this.Id);
     if (pageModel != null)
     {
         Rock.Attribute.Helper.LoadAttributes(pageModel);
         foreach (var category in pageModel.Attributes)
         {
             foreach (var attribute in category.Value)
             {
                 Rock.Attribute.Helper.SaveAttributeValues(pageModel, attribute, this.AttributeValues[attribute.Key].Value, personId);
             }
         }
     }
 }
Example #3
0
 /// <summary>
 /// Saves the attribute values for the page
 /// </summary>
 /// <param name="personId">The person id.</param>
 public void SaveAttributeValues(int? personId)
 {
     Rock.CMS.PageService pageService = new CMS.PageService();
     Rock.CMS.Page pageModel = pageService.Get( this.Id );
     if ( pageModel != null )
     {
         Rock.Attribute.Helper.LoadAttributes( pageModel );
         foreach ( var category in pageModel.Attributes )
             foreach ( var attribute in category.Value )
                 Rock.Attribute.Helper.SaveAttributeValue( pageModel, attribute, this.AttributeValues[attribute.Key].Value, personId );
     }
 }
Example #4
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="id"></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.CMS.PageService pageService = new CMS.PageService();
                Rock.CMS.Page pageModel = pageService.Get( id );
                if ( pageModel != null )
                {
                    Rock.Attribute.Helper.LoadAttributes( pageModel );

                    page = Page.CopyModel( pageModel );

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

                    return page;
                }
                else
                    return null;

            }
        }