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


C# GroupMemberService.GetByPersonId方法代码示例

本文整理汇总了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();
            }
        }
开发者ID:CentralAZ,项目名称:Rockit-CentralAZ,代码行数:58,代码来源:FamilySelect.ascx.cs


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