本文整理汇总了C#中Rock.Model.GroupMemberService.GetByPersonId方法的典型用法代码示例。如果您正苦于以下问题:C# GroupMemberService.GetByPersonId方法的具体用法?C# GroupMemberService.GetByPersonId怎么用?C# GroupMemberService.GetByPersonId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rock.Model.GroupMemberService
的用法示例。
在下文中一共展示了GroupMemberService.GetByPersonId方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: rGridPersonResults_AddExistingPerson
/// <summary>
/// Handles the RowCommand event of the grdPersonSearchResults control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="GridViewCommandEventArgs"/> instance containing the event data.</param>
protected void rGridPersonResults_AddExistingPerson( object sender, GridViewCommandEventArgs e )
{
if ( e.CommandName == "Add" )
{
var rockContext = new RockContext();
GroupMemberService groupMemberService = new GroupMemberService( rockContext );
int index = int.Parse( e.CommandArgument.ToString() );
int personId = int.Parse( rGridPersonResults.DataKeys[index].Value.ToString() );
var family = CurrentCheckInState.CheckIn.Families.Where( f => f.Selected ).FirstOrDefault();
if ( family != null )
{
var checkInPerson = new CheckInPerson();
checkInPerson.Person = new PersonService( rockContext ).Get( personId ).Clone( false );
var isPersonInFamily = family.People.Any( p => p.Person.Id == checkInPerson.Person.Id );
if ( !isPersonInFamily )
{
if ( personVisitorType.Value != "Visitor" )
{
// TODO: DT: Is this right? Not sure this is the best way to set family id
var groupMember = groupMemberService.GetByPersonId( personId ).FirstOrDefault();
groupMember.GroupId = family.Group.Id;
rockContext.SaveChanges();
checkInPerson.FamilyMember = true;
hfSelectedPerson.Value += personId + ",";
}
else
{
AddVisitorGroupMemberRoles( family, personId );
checkInPerson.FamilyMember = false;
hfSelectedVisitor.Value += personId + ",";
}
checkInPerson.Selected = true;
family.People.Add( checkInPerson );
ProcessFamily();
}
mpeAddPerson.Hide();
}
else
{
string errorMsg = "<ul><li>You have to pick a family to add this person to.</li></ul>";
maWarning.Show( errorMsg, Rock.Web.UI.Controls.ModalAlertType.Warning );
}
}
else
{
mpeAddPerson.Show();
BindPersonGrid();
}
}