当前位置: 首页>>代码示例>>C#>>正文


C# PersonService.Sort方法代码示例

本文整理汇总了C#中Rock.Model.PersonService.Sort方法的典型用法代码示例。如果您正苦于以下问题:C# PersonService.Sort方法的具体用法?C# PersonService.Sort怎么用?C# PersonService.Sort使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Rock.Model.PersonService的用法示例。


在下文中一共展示了PersonService.Sort方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: BindGrid

        /// <summary>
        /// Binds the grid.
        /// </summary>
        private void BindGrid()
        {
            var rockContext = new RockContext();
            var restUserRecordTypeId = DefinedValueCache.Read( Rock.SystemGuid.DefinedValue.PERSON_RECORD_TYPE_RESTUSER.AsGuid() ).Id;
            var activeRecordStatusValueId = DefinedValueCache.Read( Rock.SystemGuid.DefinedValue.PERSON_RECORD_STATUS_ACTIVE.AsGuid() ).Id;
            var queryable = new PersonService( rockContext ).Queryable()
                .Where( q => q.RecordTypeValueId == restUserRecordTypeId && q.RecordStatusValueId == activeRecordStatusValueId );

            SortProperty sortProperty = gRestKeyList.SortProperty;
            if ( sortProperty != null )
            {
                gRestKeyList.DataSource = queryable.Sort( sortProperty ).ToList();
            }
            else
            {
                gRestKeyList.DataSource = queryable.OrderBy( q => q.LastName ).ToList();
            }

            gRestKeyList.DataBind();
        }
开发者ID:tcavaletto,项目名称:Rock-CentralAZ,代码行数:23,代码来源:RestKeyList.ascx.cs

示例2: BindGrid

        /// <summary>
        /// Binds the grid.
        /// </summary>
        private void BindGrid()
        {
            var rockContext = new RockContext();
            var recordTypeValueId = DefinedValueCache.Read( Rock.SystemGuid.DefinedValue.PERSON_RECORD_TYPE_BUSINESS.AsGuid() ).Id;

            var queryable = new PersonService( rockContext ).Queryable()
                .Where( q => q.RecordTypeValueId == recordTypeValueId );

            var businessName = string.Empty;
            bool viaSearch = false;

            // Use the name passed in the page parameter if given
            if ( !string.IsNullOrWhiteSpace( PageParameter( "SearchTerm" ) ) )
            {
                viaSearch = true;
                gfBusinessFilter.Visible = false;
                businessName = PageParameter( "SearchTerm" );
            }
            else
            {
                // Business Name Filter
                businessName = gfBusinessFilter.GetUserPreference( "Business Name" );
            }

            if ( !string.IsNullOrWhiteSpace( businessName ) )
            {
                queryable = queryable.Where( a => a.LastName.Contains( businessName ) );
            }

            if ( ! viaSearch )
            {
                var activeRecordStatusValueId = DefinedValueCache.Read( Rock.SystemGuid.DefinedValue.PERSON_RECORD_STATUS_ACTIVE.AsGuid() ).Id;
                string activeFilterValue = gfBusinessFilter.GetUserPreference( "Active Status" );
                if ( activeFilterValue == "inactive" )
                {
                    queryable = queryable.Where( b => b.RecordStatusValueId != activeRecordStatusValueId );
                }
                else if ( activeFilterValue == "active" )
                {
                    queryable = queryable.Where( b => b.RecordStatusValueId == activeRecordStatusValueId );
                }

                SortProperty sortProperty = gBusinessList.SortProperty;
                if ( sortProperty != null )
                {
                    queryable = queryable.Sort( sortProperty );
                }
                else
                {
                    queryable = queryable.OrderBy( q => q.LastName );
                }
            }

            var groupMemberQuery = new GroupMemberService( rockContext ).Queryable();

            var businessList = queryable.Select( b => new
            {
                Id = b.Id,
                b.LastName,
                BusinessName = b.LastName,
                PhoneNumber = b.PhoneNumbers.FirstOrDefault().NumberFormatted,
                Email = b.Email,
                Address = b.Members
                                .Where( m => m.Group.GroupType.Guid.ToString() == Rock.SystemGuid.GroupType.GROUPTYPE_FAMILY )
                                .SelectMany( m => m.Group.GroupLocations )
                                .FirstOrDefault()
                                .Location,
                Contacts = b.Members
                                .Where( m => m.Group.GroupType.Guid.ToString() == Rock.SystemGuid.GroupType.GROUPTYPE_KNOWN_RELATIONSHIPS )
                                .SelectMany( m => m.Group.Members)
                                .Where( p => p.GroupRole.Guid.ToString() == Rock.SystemGuid.GroupRole.GROUPROLE_KNOWN_RELATIONSHIPS_OWNER && p.PersonId != b.Id)
                                .Select( p => p.Person.LastName + ", " + p.Person.NickName)
            } );

            if ( viaSearch && businessList.ToList().Count == 1 )
            {
                ShowDetailForm( businessList.ToList()[0].Id );
            }
            else
            {
                gBusinessList.EntityTypeId = EntityTypeCache.Read<Person>().Id;
                gBusinessList.DataSource = businessList.ToList();
                gBusinessList.DataBind();
            }
        }
开发者ID:NewPointe,项目名称:Rockit,代码行数:88,代码来源:BusinessList.ascx.cs

示例3: BindGrid

        /// <summary>
        /// Binds the grid.
        /// </summary>
        private void BindGrid()
        {
            var rockContext = new RockContext();
            var recordTypeValueId = DefinedValueCache.Read( Rock.SystemGuid.DefinedValue.PERSON_RECORD_TYPE_BUSINESS.AsGuid() ).Id;
            var activeRecordStatusValueId = DefinedValueCache.Read( Rock.SystemGuid.DefinedValue.PERSON_RECORD_STATUS_ACTIVE.AsGuid() ).Id;
            int? businessRoleId = new GroupTypeRoleService( rockContext ).Queryable()
                .Where( r =>
                    r.Guid.Equals( new Guid( Rock.SystemGuid.GroupRole.GROUPROLE_KNOWN_RELATIONSHIPS_BUSINESS ) ) )
                .Select( r => r.Id )
                .FirstOrDefault();
            var queryable = new PersonService( rockContext ).Queryable()
                .Where( q => q.RecordTypeValueId == recordTypeValueId && q.RecordStatusValueId == activeRecordStatusValueId );

            // Business Name Filter
            var businessName = gfBusinessFilter.GetUserPreference( "Business Name" );
            if ( !string.IsNullOrWhiteSpace( businessName ) )
            {
                queryable = queryable.Where( a => a.FirstName.Contains( businessName ) );
            }

            // Owner Filter
            int ownerId = 0;
            if ( int.TryParse( gfBusinessFilter.GetUserPreference( "Owner" ), out ownerId ) && ownerId != 0 )
            {
                var members = queryable.SelectMany( a => a.Members ).ToList();
                foreach ( var member in members )
                {
                    if ( member.GroupRoleId == businessRoleId )
                    {
                        var groupMemberService = new GroupMemberService( rockContext );
                        var owner = groupMemberService.GetInverseRelationship( member, false, CurrentPersonAlias );
                        if ( owner.PersonId != ownerId )
                        {
                            queryable = queryable.Where( a => a.Id != member.PersonId );
                        }
                    }
                }
            }

            SortProperty sortProperty = gBusinessList.SortProperty;
            if ( sortProperty != null )
            {
                gBusinessList.DataSource = queryable.Sort( sortProperty ).ToList();
            }
            else
            {
                gBusinessList.DataSource = queryable.OrderBy( q => q.FirstName ).ToList();
            }

            gBusinessList.DataBind();
        }
开发者ID:CentralAZ,项目名称:Rockit-CentralAZ,代码行数:54,代码来源:BusinessList.ascx.cs

示例4: BindGrid

        /// <summary>
        /// Binds the grid.
        /// </summary>
        private void BindGrid()
        {
            var rockContext = new RockContext();
            var recordTypeValueId = DefinedValueCache.Read( Rock.SystemGuid.DefinedValue.PERSON_RECORD_TYPE_BUSINESS.AsGuid() ).Id;

            var queryable = new PersonService( rockContext ).Queryable()
                .Where( q => q.RecordTypeValueId == recordTypeValueId );

            // Business Name Filter
            var businessName = gfBusinessFilter.GetUserPreference( "Business Name" );
            if ( !string.IsNullOrWhiteSpace( businessName ) )
            {
                queryable = queryable.Where( a => a.FirstName.Contains( businessName ) );
            }

            var activeRecordStatusValueId = DefinedValueCache.Read( Rock.SystemGuid.DefinedValue.PERSON_RECORD_STATUS_ACTIVE.AsGuid() ).Id;
            string activeFilterValue = gfBusinessFilter.GetUserPreference( "Active Status" );
            if (activeFilterValue == "inactive")
            {
                queryable = queryable.Where( b => b.RecordStatusValueId != activeRecordStatusValueId );
            }
            else if (activeFilterValue == "active")
            {
                queryable = queryable.Where( b => b.RecordStatusValueId == activeRecordStatusValueId );
            }

            SortProperty sortProperty = gBusinessList.SortProperty;
            if ( sortProperty != null )
            {
                gBusinessList.DataSource = queryable.Sort( sortProperty ).ToList();
            }
            else
            {
                gBusinessList.DataSource = queryable.OrderBy( q => q.FirstName ).ToList();
            }

            gBusinessList.DataBind();
        }
开发者ID:Ganon11,项目名称:Rock,代码行数:41,代码来源:BusinessList.ascx.cs

示例5: BindGrid

        /// <summary>
        /// Binds the grid.
        /// </summary>
        private void BindGrid()
        {
            if ( CurrentPersonAlias != null )
            {
                var rockContext = new RockContext();

                int personEntityTypeId = EntityTypeCache.Read( "Rock.Model.Person" ).Id;
                var personIds = new FollowingService( new RockContext() ).Queryable()
                    .Where( f =>
                        f.EntityTypeId == personEntityTypeId &&
                        f.PersonAliasId == CurrentPersonAlias.Id )
                    .Select( f => f.EntityId )
                    .Distinct()
                    .ToList();

                var qry = new PersonService( rockContext ).Queryable()
                    .Where( p => personIds.Contains( p.Id ) );

                // Sort
                SortProperty sortProperty = gFollowings.SortProperty;
                if ( sortProperty == null )
                {
                    sortProperty = new SortProperty( new GridViewSortEventArgs( "LastName,NickName", SortDirection.Ascending ) );
                }

                Guid homePhoneGuid = Rock.SystemGuid.DefinedValue.PERSON_PHONE_TYPE_HOME.AsGuid();
                Guid cellPhoneGuid = Rock.SystemGuid.DefinedValue.PERSON_PHONE_TYPE_MOBILE.AsGuid();
                Guid adultGuid = Rock.SystemGuid.GroupRole.GROUPROLE_FAMILY_MEMBER_ADULT.AsGuid();
                Guid marriedGuid = Rock.SystemGuid.DefinedValue.PERSON_MARITAL_STATUS_MARRIED.AsGuid();

                gFollowings.DataSource = qry.Sort( sortProperty )
                    .Select( p => new
                        {
                            p.Id,
                            p.LastName,
                            p.NickName,
                            p.BirthDate,
                            p.Email,
                            HomePhone = p.PhoneNumbers
                                .Where( n => n.NumberTypeValue.Guid.Equals(homePhoneGuid))
                                .Select( n => n.NumberFormatted)
                                .FirstOrDefault(),
                            CellPhone = p.PhoneNumbers
                                .Where( n => n.NumberTypeValue.Guid.Equals( cellPhoneGuid ) )
                                .Select( n => n.NumberFormatted )
                                .FirstOrDefault(),
                            SpouseName = p.Members
                                .Where( m =>
                                    p.MaritalStatusValue.Guid.Equals(marriedGuid) &&
                                    m.GroupRole.Guid.Equals(adultGuid))
                                .SelectMany( m => m.Group.Members)
                                .Where( m =>
                                    m.PersonId != p.Id &&
                                    m.GroupRole.Guid.Equals(adultGuid) &&
                                    m.Person.MaritalStatusValue.Guid.Equals(marriedGuid) )
                                .Select( s => s.Person.NickName + " " + s.Person.LastName)
                                .FirstOrDefault()
                        } ).ToList();

                gFollowings.DataBind();
            }
        }
开发者ID:Ganon11,项目名称:Rock,代码行数:65,代码来源:PersonFollowingList.ascx.cs


注:本文中的Rock.Model.PersonService.Sort方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。