コード例 #1
0
ファイル: Service.cs プロジェクト: lcbc-digital/Rock-LCBC
        /// <summary>
        /// Gets a query of the items that are followed by a specific person id
        /// </summary>
        /// <param name="personId">The person identifier.</param>
        /// <returns></returns>
        public IQueryable <T> GetFollowed(int personId)
        {
            var rockContext = this.Context as RockContext;

            var entityTypeId = EntityTypeCache.Get(typeof(T), false, rockContext)?.Id;

            if (!entityTypeId.HasValue)
            {
                return(null);
            }

            var query = new Rock.Model.FollowingService(rockContext).GetFollowedItems(entityTypeId.Value, personId).Cast <T>();

            return(query);
        }
コード例 #2
0
        /// <summary>
        /// Gets a query of the items that are followed by a specific person id
        /// </summary>
        /// <param name="personId">The person identifier.</param>
        /// <returns></returns>
        public IQueryable <T> GetFollowed(int personId)
        {
            var rockContext = this.Context as RockContext;

            var entityType = EntityTypeCache.Get(typeof(T), false, rockContext);

            if (entityType != null)
            {
                var ids = new Rock.Model.FollowingService(rockContext)
                          .Queryable()
                          .Where(f =>
                                 f.EntityTypeId == entityType.Id &&
                                 f.PersonAlias != null &&
                                 f.PersonAlias.PersonId == personId)
                          .Select(f => f.PersonAlias.PersonId);

                return(Queryable().Where(t => ids.Contains(t.Id)));
            }

            return(null);
        }
コード例 #3
0
        /// <summary>
        /// Gets a quety of the followers of a particular item
        /// </summary>
        /// <param name="id">The identifier.</param>
        /// <returns></returns>
        public IQueryable <Rock.Model.Person> GetFollowers(int id)
        {
            var rockContext = this.Context as RockContext;

            var entityType = EntityTypeCache.Get(typeof(T), false, rockContext);

            if (entityType != null)
            {
                var followerPersonIds = new Rock.Model.FollowingService(rockContext)
                                        .Queryable()
                                        .Where(f =>
                                               f.EntityTypeId == entityType.Id &&
                                               f.EntityId == id)
                                        .Select(f => f.PersonAlias.PersonId);

                return(new Rock.Model.PersonService(rockContext)
                       .Queryable()
                       .Where(p => followerPersonIds.Contains(p.Id)));
            }

            return(null);
        }