GetFollowedItems() public method

Gets the entity query For example: If the EntityTypeId is GroupMember, this will return a GroupMember query of group members that the person is following
public GetFollowedItems ( int entityTypeId, int personId ) : IQueryable
entityTypeId int The entity type identifier.
personId int The person identifier.
return IQueryable
        protected void LoadContent()
        {
            var mergeFields = Rock.Lava.LavaHelper.GetCommonMergeFields( this.RockPage, this.CurrentPerson );

            var entityType = EntityTypeCache.Read(GetAttributeValue("EntityType").AsGuid());

            if ( entityType != null )
            {

                RockContext rockContext = new RockContext();

                int personId = this.CurrentPersonId.Value;

                var followingService = new FollowingService( rockContext );
                IQueryable<IEntity> qryFollowedItems = followingService.GetFollowedItems( entityType.Id, personId );

                int quantity = GetAttributeValue( "MaxResults" ).AsInteger();
                var items = qryFollowedItems.Take(quantity + 1).ToList();

                bool hasMore = (quantity < items.Count);

                mergeFields.Add( "FollowingItems", items.Take( quantity ) );
                mergeFields.Add( "HasMore", hasMore );
                mergeFields.Add( "EntityType", entityType.FriendlyName );
                mergeFields.Add( "LinkUrl", GetAttributeValue( "LinkUrl" ) );
                mergeFields.Add( "Quantity", quantity );

                string template = GetAttributeValue( "LavaTemplate" );
                lContent.Text = template.ResolveMergeFields( mergeFields );

                // show debug info
                if ( GetAttributeValue( "EnableDebug" ).AsBoolean() && IsUserAuthorized( Authorization.EDIT ) )
                {
                    lDebug.Visible = true;
                    lDebug.Text = mergeFields.lavaDebugInfo();
                }
            }
            else
            {
                lContent.Text = string.Format( "<div class='alert alert-warning'>Please configure an entity in the block settings." );

            }
        }
Beispiel #2
0
        protected void LoadContent()
        {
            var mergeFields = new Dictionary<string, object>();
            mergeFields.Add( "CurrentPerson", CurrentPerson );
            var globalAttributeFields = Rock.Web.Cache.GlobalAttributesCache.GetMergeFields( CurrentPerson );
            globalAttributeFields.ToList().ForEach( d => mergeFields.Add( d.Key, d.Value ) );

            var entityType = EntityTypeCache.Read(GetAttributeValue("EntityType").AsGuid());

            if ( entityType != null )
            {

                RockContext rockContext = new RockContext();

                int entityTypeId = EntityTypeCache.GetId<Group>().Value;
                int personId = this.CurrentPersonId.Value;

                var followingService = new FollowingService( rockContext );
                IQueryable<IEntity> qryFollowedItems = followingService.GetFollowedItems( entityTypeId, personId );

                mergeFields.Add( "FollowingItems", qryFollowedItems );

                mergeFields.Add( "EntityType", entityType.FriendlyName );
                mergeFields.Add( "LinkUrl", GetAttributeValue( "LinkUrl" ) );

                string template = GetAttributeValue( "LavaTemplate" );
                lContent.Text = template.ResolveMergeFields( mergeFields );

                // show debug info
                if ( GetAttributeValue( "EnableDebug" ).AsBoolean() && IsUserAuthorized( Authorization.EDIT ) )
                {
                    lDebug.Visible = true;
                    lDebug.Text = mergeFields.lavaDebugInfo();
                }
            }
            else
            {
                lContent.Text = string.Format( "<div class='alert alert-warning'>Please configure an entity in the block settings." );

            }
        }