本文整理汇总了C#中Rock.Model.PersonService.GetSimilarNames方法的典型用法代码示例。如果您正苦于以下问题:C# PersonService.GetSimilarNames方法的具体用法?C# PersonService.GetSimilarNames怎么用?C# PersonService.GetSimilarNames使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rock.Model.PersonService
的用法示例。
在下文中一共展示了PersonService.GetSimilarNames方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BindGrid
//.........这里部分代码省略.........
var personIds = phoneService.GetPersonIdsByNumber( term );
people = personService.Queryable().Where( p => personIds.Contains( p.Id ) );
break;
}
case ( "address" ):
{
var groupMemberService = new GroupMemberService( rockContext );
var personIds2 = groupMemberService.GetPersonIdsByHomeAddress( term );
people = personService.Queryable().Where( p => personIds2.Contains( p.Id ) );
break;
}
case ( "email" ):
{
people = personService.Queryable().Where( p => p.Email.Contains( term ) );
break;
}
}
var personIdList = people.Select( p => p.Id ).ToList();
people = personService.Queryable(true).Where( p => personIdList.Contains( p.Id ) );
SortProperty sortProperty = gPeople.SortProperty;
if ( sortProperty != null )
{
people = people.Sort( sortProperty );
}
else
{
people = people.OrderBy( p => p.LastName ).ThenBy( p => p.FirstName );
}
Guid familyGuid = new Guid( Rock.SystemGuid.GroupType.GROUPTYPE_FAMILY );
Guid homeAddressTypeGuid = new Guid( Rock.SystemGuid.DefinedValue.GROUP_LOCATION_TYPE_HOME );
var personList = people.Select( p => new PersonSearchResult
{
Id = p.Id,
FirstName = p.FirstName,
NickName = p.NickName,
LastName = p.LastName,
BirthDate = p.BirthDate,
BirthYear = p.BirthYear,
BirthMonth = p.BirthMonth,
BirthDay = p.BirthDay,
ConnectionStatusValueId = p.ConnectionStatusValueId,
RecordStatusValueId = p.RecordStatusValueId,
RecordTypeValueId = p.RecordTypeValueId,
SuffixValueId = p.SuffixValueId,
IsDeceased = p.IsDeceased,
Email = p.Email,
Gender = p.Gender,
PhotoId = p.PhotoId,
CampusIds = p.Members
.Where( m =>
m.Group.GroupType.Guid.Equals( familyGuid ) &&
m.Group.CampusId.HasValue )
.Select( m => m.Group.CampusId.Value )
.ToList(),
HomeAddresses = p.Members
.Where( m => m.Group.GroupType.Guid == familyGuid )
.SelectMany( m => m.Group.GroupLocations )
.Where( gl => gl.GroupLocationTypeValue.Guid.Equals( homeAddressTypeGuid ) )
.Select( gl => gl.Location )
} ).ToList();
if ( personList.Count == 1 )
{
Response.Redirect( string.Format( "~/Person/{0}", personList[0].Id ), false );
Context.ApplicationInstance.CompleteRequest();
}
else
{
if ( type.ToLower() == "name" )
{
var similarNames = personService.GetSimilarNames( term,
personList.Select( p => p.Id ).ToList(), true );
if ( similarNames.Any() )
{
var hyperlinks = new List<string>();
foreach ( string name in similarNames.Distinct() )
{
var pageRef = CurrentPageReference;
pageRef.Parameters["SearchTerm"] = name;
hyperlinks.Add( string.Format( "<a href='{0}'>{1}</a>", pageRef.BuildUrl(), name ) );
}
string altNames = string.Join( ", ", hyperlinks );
nbNotice.Text = string.Format( "Other Possible Matches: {0}", altNames );
nbNotice.Visible = true;
}
}
_inactiveStatus = DefinedValueCache.Read( Rock.SystemGuid.DefinedValue.PERSON_RECORD_STATUS_INACTIVE );
gPeople.EntityTypeId = EntityTypeCache.GetId<Person>();
gPeople.DataSource = personList;
gPeople.DataBind();
}
}
}