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


C# PersonService.Select方法代码示例

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


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

示例1: GetExpression

        /// <summary>
        /// Gets the expression.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="entityIdProperty">The entity identifier property.</param>
        /// <param name="selection">The selection.</param>
        /// <returns></returns>
        public override System.Linq.Expressions.Expression GetExpression( Data.RockContext context, System.Linq.Expressions.MemberExpression entityIdProperty, string selection )
        {
            bool showAsLink = this.GetAttributeValueFromSelection( "ShowAsLink", selection ).AsBooleanOrNull() ?? false;
            int displayOrder = this.GetAttributeValueFromSelection( "DisplayOrder", selection ).AsIntegerOrNull() ?? 0;
            var personQry = new PersonService( context ).Queryable();
            IQueryable<string> personLinkQuery;

            string basePersonUrl = System.Web.VirtualPathUtility.ToAbsolute( "~/Person/" );

            if ( showAsLink )
            {
                // return string in format: <a href='/person/{personId}'>LastName, NickName</a>
                if ( displayOrder == 0 )
                {
                    personLinkQuery = personQry.Select( p => "<a href='" + basePersonUrl + p.Id.ToString() + "'>" + p.NickName + " " + p.LastName + "</a>" );
                }
                else
                {
                    personLinkQuery = personQry.Select( p => "<a href='" + basePersonUrl + p.Id.ToString() + "'>" + p.LastName + ", " + p.NickName + "</a>" );
                }
            }
            else
            {
                if ( displayOrder == 0 )
                {
                    personLinkQuery = personQry.Select( p => p.NickName + " " + p.LastName );
                }
                else
                {
                    personLinkQuery = personQry.Select( p => p.LastName + ", " + p.NickName );
                }
            }

            return SelectExpressionExtractor.Extract( personLinkQuery, entityIdProperty, "p" );
        }
开发者ID:NewSpring,项目名称:Rock,代码行数:42,代码来源:PersonLinkSelect.cs

示例2: DisplayResults

        private void DisplayResults()
        {
            RockContext rockContext = new RockContext();

            var statementYear = RockDateTime.Now.Year;

            if ( Request["StatementYear"] != null )
            {
                Int32.TryParse( Request["StatementYear"].ToString(), out statementYear );
            }

            FinancialTransactionDetailService financialTransactionDetailService = new FinancialTransactionDetailService( rockContext );

            var qry = financialTransactionDetailService.Queryable().AsNoTracking()
                        .Where( t=> t.Transaction.AuthorizedPersonAlias.Person.GivingId == CurrentPerson.GivingId);

            qry = qry.Where( t => t.Transaction.TransactionDateTime.Value.Year == statementYear );

            if ( string.IsNullOrWhiteSpace( GetAttributeValue( "Accounts" ) ) )
            {
                qry = qry.Where( t => t.Account.IsTaxDeductible );
            } else
            {
                var accountGuids = GetAttributeValue( "Accounts" ).Split( ',' ).Select( Guid.Parse ).ToList();
                qry = qry.Where( t => accountGuids.Contains( t.Account.Guid ) );
            }

            qry = qry.OrderByDescending( t => t.Transaction.TransactionDateTime );

            var mergeFields = new Dictionary<string, object>();
            mergeFields.Add( "StatementStartDate", "1/1/" + statementYear.ToString() );
            if ( statementYear == RockDateTime.Now.Year )
            {
                mergeFields.Add( "StatementEndDate", RockDateTime.Now );
            }
            else
            {
                mergeFields.Add( "StatementEndDate", "12/31/" + statementYear.ToString() );
            }

            var familyGroupTypeId = GroupTypeCache.Read( Rock.SystemGuid.GroupType.GROUPTYPE_FAMILY ).Id;
            var groupMemberQry = new GroupMemberService( rockContext ).Queryable().Where( m => m.Group.GroupTypeId == familyGroupTypeId );

            // get giving group members in order by family role (adult -> child) and then gender (male -> female)
            var givingGroup = new PersonService( rockContext ).Queryable().AsNoTracking()
                                    .Where( p => p.GivingId == CurrentPerson.GivingId )
                                    .GroupJoin(
                                        groupMemberQry,
                                        p => p.Id,
                                        m => m.PersonId,
                                        (p, m) => new {p, m})
                                    .SelectMany( x => x.m.DefaultIfEmpty(), (y,z) => new { Person = y.p, GroupMember = z} )
                                    .Select( p => new { FirstName = p.Person.NickName, LastName = p.Person.LastName, FamilyRoleOrder = p.GroupMember.GroupRole.Order, Gender = p.Person.Gender, PersonId = p.Person.Id } )
                                    .DistinctBy(p => p.PersonId)
                                    .OrderBy(p => p.FamilyRoleOrder).ThenBy(p => p.Gender)
                                    .ToList();

            // make a list of person ids in the giving group
            List<int> givingGroupIdsOnly = new List<int>();
            foreach ( var x in givingGroup )
            {
                givingGroupIdsOnly.Add(x.PersonId);
            }

            string salutation = string.Empty;

            if (givingGroup.GroupBy(g => g.LastName).Count() == 1 )
            {
                salutation = string.Join( ", ", givingGroup.Select( g => g.FirstName ) ) + " " + givingGroup.FirstOrDefault().LastName;
                if ( salutation.Contains( "," ) )
                {
                    salutation = salutation.ReplaceLastOccurrence( ",", " &" );
                }
            }
            else
            {
                salutation = string.Join( ", ", givingGroup.Select( g => g.FirstName + " " + g.LastName ) );
                if ( salutation.Contains( "," ) )
                {
                    salutation = salutation.ReplaceLastOccurrence( ",", " &" );
                }
            }
            mergeFields.Add( "Salutation", salutation );

            var homeAddress = CurrentPerson.GetHomeLocation();
            if ( homeAddress != null )
            {
                mergeFields.Add( "StreetAddress1", homeAddress.Street1 );
                mergeFields.Add( "StreetAddress2", homeAddress.Street2 );
                mergeFields.Add( "City", homeAddress.City );
                mergeFields.Add( "State", homeAddress.State );
                mergeFields.Add( "PostalCode", homeAddress.PostalCode );
                mergeFields.Add( "Country", homeAddress.Country );
            }
            else
            {
                mergeFields.Add( "StreetAddress1", string.Empty );
                mergeFields.Add( "StreetAddress2", string.Empty );
                mergeFields.Add( "City", string.Empty );
                mergeFields.Add( "State", string.Empty );
//.........这里部分代码省略.........
开发者ID:NewPointe,项目名称:Rockit,代码行数:101,代码来源:ContributionStatementLava.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 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

示例4: Search

        /// <summary>
        /// Returns a list of matching people
        /// </summary>
        /// <param name="searchterm"></param>
        /// <returns></returns>
        public override IQueryable<string> Search( string searchterm )
        {
            bool allowFirstNameSearch = false;
            if ( !bool.TryParse( GetAttributeValue( "FirstNameSearch" ), out allowFirstNameSearch ) )
            {
                allowFirstNameSearch = false;
            }

            bool reversed = false;
            var qry = new PersonService( new RockContext() ).GetByFullNameOrdered( searchterm, true, false, allowFirstNameSearch, out reversed );
            return qry
                .Select( p => ( reversed ?
                    p.LastName + ", " + p.NickName:
                    p.NickName + " " + p.LastName) )
                .Distinct();
        }
开发者ID:tcavaletto,项目名称:Rock-CentralAZ,代码行数:21,代码来源:Name.cs

示例5: GetExpression

        /// <summary>
        /// Gets the expression.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="entityIdProperty">The entity identifier property.</param>
        /// <param name="selection">The selection.</param>
        /// <returns></returns>
        public override System.Linq.Expressions.Expression GetExpression( Data.RockContext context, System.Linq.Expressions.MemberExpression entityIdProperty, string selection )
        {
            bool showAsLink = this.GetAttributeValueFromSelection( "ShowAsLink", selection ).AsBooleanOrNull() ?? false;
            int displayOrder = this.GetAttributeValueFromSelection( "DisplayOrder", selection ).AsIntegerOrNull() ?? 0;
            var personQry = new PersonService( context ).Queryable();
            IQueryable<string> personLinkQuery;

            if ( showAsLink )
            {
                // return string in format: <a href='/person/{personId}'>LastName, NickName</a>
                // prepend it with <!--LastName, NickName--> so that Sorting Works as expected
                if ( displayOrder == 0 )
                {
                    personLinkQuery = personQry.Select( p => "<!--" + p.NickName + " " + p.LastName + "--><a href='/person/" + p.Id.ToString() + "'>" + p.NickName + " " + p.LastName + "</a>" );
                }
                else
                {
                    personLinkQuery = personQry.Select( p => "<!--" + p.LastName + ", " + p.NickName + "--><a href='/person/" + p.Id.ToString() + "'>" + p.LastName + ", " + p.NickName + "</a>" );
                }
            }
            else
            {
                if ( displayOrder == 0 )
                {
                    personLinkQuery = personQry.Select( p => p.NickName + " " + p.LastName );
                }
                else
                {
                    personLinkQuery = personQry.Select( p => p.LastName + ", " + p.NickName );
                }
            }

            return SelectExpressionExtractor.Extract<Rock.Model.Person>( personLinkQuery, entityIdProperty, "p" );
        }
开发者ID:tcavaletto,项目名称:Rock-CentralAZ,代码行数:41,代码来源:PersonLinkSelect.cs

示例6: Search

        /// <summary>
        /// Returns a list of matching people
        /// </summary>
        /// <param name="searchterm"></param>
        /// <returns></returns>
        public override IQueryable<string> Search( string searchterm )
        {
            bool allowFirstNameSearch = GetAttributeValue( "FirstNameSearch" ).AsBooleanOrNull() ?? false;

            bool reversed = false;
            var qry = new PersonService( new RockContext() ).GetByFullNameOrdered( searchterm, true, false, allowFirstNameSearch, out reversed );

            IQueryable<string> resultQry;

            if ( reversed )
            {
                resultQry = qry.Select( p => p.LastName + ", " + p.NickName).Distinct();
            }
            else
            {
                resultQry = qry.Select( p => p.NickName + " " + p.LastName ).Distinct();
            }

            return resultQry;
        }
开发者ID:NewSpring,项目名称:Rock,代码行数:25,代码来源:Name.cs


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