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


C# PersonService.Get方法代码示例

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


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

示例1: Page_Load

        protected void Page_Load(object sender, EventArgs e)
        {
            //Set the person picker to the currently logged in person.
            PersonService personService = new PersonService(rockContext);
            var personObject = personService.Get(CurrentPerson.Guid);

            //Get the person from the URL
            string qsPersonId = PageParameter("PersonId");
            int iPersonId = Int32.Parse(qsPersonId);

            var thePerson = personService.Get(iPersonId);

            //Get the URL encoded key from the person object
            var urlEncodedKey = thePerson.UrlEncodedKey;
            PageViewHistoryUrl = ResolveUrl("~/page/279?Person=" + urlEncodedKey);
        }
开发者ID:RMRDevelopment,项目名称:Rockit,代码行数:16,代码来源:PersonPageHistoryBlock.ascx.cs

示例2: DeleteKnownRelationship

        public void DeleteKnownRelationship( int personId, int relatedPersonId, int relationshipRoleId )
        {
            SetProxyCreation( true );
            var rockContext = this.Service.Context as RockContext;
            var personService = new PersonService( rockContext );
            var person = personService.Get( personId );
            var relatedPerson = personService.Get( relatedPersonId );

            CheckCanEdit( person );
            CheckCanEdit( relatedPerson );

            System.Web.HttpContext.Current.Items.Add( "CurrentPerson", GetPerson() );

            var groupMemberService = new GroupMemberService( rockContext );
            groupMemberService.DeleteKnownRelationship( personId, relatedPersonId, relationshipRoleId );
        }
开发者ID:,项目名称:,代码行数:16,代码来源:

示例3: CreateKnownRelationship

        public System.Net.Http.HttpResponseMessage CreateKnownRelationship( int personId, int relatedPersonId, int relationshipRoleId )
        {
            SetProxyCreation( true );
            var rockContext = this.Service.Context as RockContext;
            var personService = new PersonService(rockContext);
            var person = personService.Get(personId);
            var relatedPerson = personService.Get(relatedPersonId);

            CheckCanEdit( person );
            CheckCanEdit( relatedPerson );

            System.Web.HttpContext.Current.Items.Add( "CurrentPerson", GetPerson() );

            var groupMemberService = new GroupMemberService(rockContext);
            groupMemberService.CreateKnownRelationship( personId, relatedPersonId, relationshipRoleId );

            return ControllerContext.Request.CreateResponse( HttpStatusCode.Created );
        }
开发者ID:,项目名称:,代码行数:18,代码来源:

示例4: btnSubmit_Click

        /// <summary>
        /// Handles the Click event of the btnSubmit control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        protected void btnSubmit_Click( object sender, EventArgs e )
        {
            if (_person != null)
            {
                var rockContext = new RockContext();
                var service = new PersonService( rockContext );
                var person = service.Get(_person.Id);
                if ( person != null )
                {
                    switch ( rblEmailPreference.SelectedValue )
                    {
                        case "0":
                            {
                                person.EmailPreference = EmailPreference.EmailAllowed;
                                break;
                            }
                        case "1":
                            {
                                person.EmailPreference = EmailPreference.NoMassEmails;
                                break;
                            }
                        case "2":
                        case "3":
                            {
                                person.EmailPreference = EmailPreference.DoNotEmail;
                                break;
                            }
                    }

                    if (rblEmailPreference.SelectedValue == "3")
                    {
                        person.RecordStatusValueId = DefinedValueCache.Read( Rock.SystemGuid.DefinedValue.PERSON_RECORD_STATUS_INACTIVE ).Id;
                        person.RecordStatusReasonValueId = ddlInactiveReason.SelectedValue.AsInteger().Value;
                        person.ReviewReasonValueId = DefinedValueCache.Read( Rock.SystemGuid.DefinedValue.PERSON_REVIEW_REASON_SELF_INACTIVATED ).Id;
                        if ( string.IsNullOrWhiteSpace( person.ReviewReasonNote ) )
                        {
                            person.ReviewReasonNote = tbInactiveNote.Text;
                        }
                        else
                        {
                            person.ReviewReasonNote += " " + tbInactiveNote.Text;
                        }
                    }
                    else
                    {
                        person.RecordStatusValueId = DefinedValueCache.Read( Rock.SystemGuid.DefinedValue.PERSON_RECORD_STATUS_ACTIVE ).Id;
                        person.RecordStatusReasonValueId = null;
                    }

                    rockContext.SaveChanges();

                    nbMessage.Visible = true;
                    return;
                }
            }
        }
开发者ID:CentralAZ,项目名称:Rockit-CentralAZ,代码行数:61,代码来源:EditEmailPreference.ascx.cs

示例5: gBusinessList_Delete

        /// <summary>
        /// Handles the Delete event of the gBusinessList control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="Rock.Web.UI.Controls.RowEventArgs"/> instance containing the event data.</param>
        protected void gBusinessList_Delete( object sender, Rock.Web.UI.Controls.RowEventArgs e )
        {
            var rockContext = new RockContext();
            PersonService service = new PersonService( rockContext );
            Person business = service.Get( e.RowKeyId );
            if ( business != null )
            {
                business.RecordStatusValueId = DefinedValueCache.Read( new Guid( Rock.SystemGuid.DefinedValue.PERSON_RECORD_STATUS_INACTIVE ) ).Id;
                rockContext.SaveChanges();
            }

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

示例6: FormatValue

        /// <summary>
        /// Returns the field's current value(s)
        /// </summary>
        /// <param name="parentControl">The parent control.</param>
        /// <param name="value">Information about the value</param>
        /// <param name="configurationValues">The configuration values.</param>
        /// <param name="condensed">Flag indicating if the value should be condensed (i.e. for use in a grid column)</param>
        /// <returns></returns>
        public override string FormatValue( System.Web.UI.Control parentControl, string value, Dictionary<string, ConfigurationValue> configurationValues, bool condensed )
        {
            string formattedValue = string.Empty;

            if ( !string.IsNullOrWhiteSpace( value ) )
            {
                var service = new PersonService();
                var person = service.Get( new Guid( value ) );
                if ( person != null )
                {
                    formattedValue = person.FullName;
                }
            }

            return base.FormatValue( parentControl, formattedValue, null, condensed );
        }
开发者ID:pkdevbox,项目名称:Rock,代码行数:24,代码来源:PersonFieldType.cs

示例7: gRestKeyList_Delete

        /// <summary>
        /// Handles the Delete event of the gRestKeyList control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="RowEventArgs"/> instance containing the event data.</param>
        protected void gRestKeyList_Delete( object sender, RowEventArgs e )
        {
            var rockContext = new RockContext();
            var personService = new PersonService( rockContext );
            var userLoginService = new UserLoginService( rockContext );
            var restUser = personService.Get( e.RowKeyId );
            if ( restUser != null )
            {
                restUser.RecordStatusValueId = DefinedValueCache.Read( new Guid( Rock.SystemGuid.DefinedValue.PERSON_RECORD_STATUS_INACTIVE ) ).Id;

                // remove all user logins for key
                foreach ( var login in restUser.Users.ToList() )
                {
                    userLoginService.Delete( login );
                }
                rockContext.SaveChanges();
            }

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

示例8: DisplaySuccess

        /// <summary>
        /// Displays the success.
        /// </summary>
        /// <param name="user">The user.</param>
        private void DisplaySuccess( Rock.Model.UserLogin user )
        {
            FormsAuthentication.SignOut();
            Rock.Security.Authorization.SetAuthCookie( tbUserName.Text, false, false );

            if ( user != null && user.PersonId.HasValue )
            {
                PersonService personService = new PersonService( new RockContext() );
                Person person = personService.Get( user.PersonId.Value );

                if ( person != null )
                {
                    try
                    {
                        string url = LinkedPageUrl( "ConfirmationPage" );
                        if ( string.IsNullOrWhiteSpace( url ) )
                        {
                            url = ResolveRockUrl( "~/ConfirmAccount" );
                        }

                        var mergeObjects = new Dictionary<string, object>();
                        mergeObjects.Add( "ConfirmAccountUrl", RootPath + url.TrimStart( new char[] { '/' } ) );

                        var personDictionary = person.ToLiquid() as Dictionary<string, object>;
                        mergeObjects.Add( "Person", personDictionary );
                        mergeObjects.Add( "User", user );

                        var recipients = new Dictionary<string, Dictionary<string, object>>();
                        recipients.Add( person.Email, mergeObjects );

                        Email.Send( GetAttributeValue( "AccountCreatedTemplate" ).AsGuid(), recipients, ResolveRockUrl( "~/" ), ResolveRockUrl( "~~/" ) );
                    }
                    catch ( SystemException ex )
                    {
                        ExceptionLogService.LogException( ex, Context, RockPage.PageId, RockPage.Site.Id, CurrentPersonAlias );
                    }

                    string returnUrl = Request.QueryString["returnurl"];
                    btnContinue.Visible = !string.IsNullOrWhiteSpace( returnUrl );

                    lSuccessCaption.Text = GetAttributeValue( "SuccessCaption" );
                    if ( lSuccessCaption.Text.Contains( "{0}" ) )
                    {
                        lSuccessCaption.Text = string.Format( lSuccessCaption.Text, person.FirstName );
                    }

                    ShowPanel( 5 );
                }
                else
                {
                    ShowErrorMessage( "Invalid Person" );
                }
            }
            else
            {
                ShowErrorMessage( "Invalid User" );
            }
        }
开发者ID:CentralAZ,项目名称:Rockit-CentralAZ,代码行数:62,代码来源:NewAccount.ascx.cs

示例9: DisplaySendLogin

        /// <summary>
        /// Displays the send login.
        /// </summary>
        /// <param name="personId">The person identifier.</param>
        /// <param name="direction">The direction.</param>
        private void DisplaySendLogin( int personId, Direction direction )
        {
            hfSendPersonId.Value = personId.ToString();

            lExistingAccountCaption.Text = GetAttributeValue( "ExistingAccountCaption" );
            if ( lExistingAccountCaption.Text.Contains( "{0}" ) )
            {
                PersonService personService = new PersonService( new RockContext() );
                Person person = personService.Get( personId );
                if ( person != null )
                {
                    lExistingAccountCaption.Text = string.Format( lExistingAccountCaption.Text, person.FirstName );
                }
            }

            ShowPanel( 2 );
        }
开发者ID:CentralAZ,项目名称:Rockit-CentralAZ,代码行数:22,代码来源:NewAccount.ascx.cs

示例10: btnSave_Click

        /// <summary>
        /// Handles the Click event of the btnSave control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        protected void btnSave_Click( object sender, EventArgs e )
        {
            // confirmation was disabled by btnSave on client-side.  So if returning without a redirect,
            // it should be enabled.  If returning with a redirect, the control won't be updated to reflect
            // confirmation being enabled, so it's ok to enable it here
            confirmExit.Enabled = true;

            if ( Page.IsValid )
            {
                confirmExit.Enabled = true;

                RockTransactionScope.WrapTransaction( () =>
                {
                    var rockContext = new RockContext();
                    var familyService = new GroupService( rockContext );
                    var familyMemberService = new GroupMemberService( rockContext );
                    var personService = new PersonService( rockContext );
                    var historyService = new HistoryService( rockContext );

                    var familyChanges = new List<string>();

                    // SAVE FAMILY
                    _family = familyService.Get( _family.Id );

                    History.EvaluateChange( familyChanges, "Family Name", _family.Name, tbFamilyName.Text );
                    _family.Name = tbFamilyName.Text;

                    int? campusId = cpCampus.SelectedValueAsInt();
                    if ( _family.CampusId != campusId )
                    {
                        History.EvaluateChange( familyChanges, "Campus",
                            _family.CampusId.HasValue ? CampusCache.Read( _family.CampusId.Value ).Name : string.Empty,
                            campusId.HasValue ? CampusCache.Read( campusId.Value ).Name : string.Empty );
                        _family.CampusId = campusId;
                    }

                    var familyGroupTypeId = _family.GroupTypeId;

                    rockContext.SaveChanges();

                    // SAVE FAMILY MEMBERS
                    int? recordStatusValueID = ddlRecordStatus.SelectedValueAsInt();
                    int? reasonValueId = ddlReason.SelectedValueAsInt();
                    var newFamilies = new List<Group>();

                    foreach ( var familyMember in FamilyMembers )
                    {
                        var memberChanges = new List<string>();
                        var demographicChanges = new List<string>();

                        var role = familyRoles.Where( r => r.Guid.Equals( familyMember.RoleGuid ) ).FirstOrDefault();
                        if ( role == null )
                        {
                            role = familyRoles.FirstOrDefault();
                        }

                        bool isChild = role != null && role.Guid.Equals( new Guid( Rock.SystemGuid.GroupRole.GROUPROLE_FAMILY_MEMBER_CHILD ) );

                        // People added to family (new or from other family)
                        if ( !familyMember.ExistingFamilyMember )
                        {
                            var groupMember = new GroupMember();

                            if ( familyMember.Id == -1 )
                            {
                                // added new person
                                demographicChanges.Add( "Created" );

                                var person = new Person();
                                person.FirstName = familyMember.FirstName;
                                person.NickName = familyMember.NickName;
                                History.EvaluateChange( demographicChanges, "First Name", string.Empty, person.FirstName );

                                person.LastName = familyMember.LastName;
                                History.EvaluateChange( demographicChanges, "Last Name", string.Empty, person.LastName );

                                person.Gender = familyMember.Gender;
                                History.EvaluateChange( demographicChanges, "Gender", null, person.Gender );

                                person.BirthDate = familyMember.BirthDate;
                                History.EvaluateChange( demographicChanges, "Birth Date", null, person.BirthDate );

                                if ( !isChild )
                                {
                                    person.GivingGroupId = _family.Id;
                                    History.EvaluateChange( demographicChanges, "Giving Group", string.Empty, _family.Name );
                                }

                                person.EmailPreference = EmailPreference.EmailAllowed;

                                groupMember.Person = person;
                            }
                            else
                            {
                                // added from other family
//.........这里部分代码省略.........
开发者ID:CentralAZ,项目名称:Rockit-CentralAZ,代码行数:101,代码来源:EditFamily.ascx.cs

示例11: ShowBusiness

 private void ShowBusiness()
 {
     int? businessId = cblBusiness.SelectedValueAsInt();
     if ( businessId.HasValue )
     {
         using ( var rockContext = new RockContext() )
         {
             var personService = new PersonService( rockContext );
             var business = personService.Get( businessId.Value );
             ShowBusiness( personService, business );
         }
     }
     else
     {
         ShowBusiness( null, null );
     }
 }
开发者ID:NewSpring,项目名称:Rock,代码行数:17,代码来源:TransactionEntry.ascx.cs

示例12: GetPerson

        /// <summary>
        /// Gets the person.
        /// </summary>
        /// <param name="create">if set to <c>true</c> [create].</param>
        /// <returns></returns>
        private Person GetPerson( bool create )
        {
            Person person = null;
            var rockContext = new RockContext();
            var personService = new PersonService( rockContext );

            Group familyGroup = null;

            int personId = ViewState["PersonId"] as int? ?? 0;
            if ( personId == 0 && _targetPerson != null )
            {
                personId = _targetPerson.Id;
            }

            if ( personId != 0 )
            {
                person = personService.Get( personId );
            }

            if ( create && ( !phGiveAsOption.Visible || tglGiveAsOption.Checked ) ) // If tglGiveOption is not checked, then person should not be null
            {
                if ( person == null )
                {
                    // Check to see if there's only one person with same email, first name, and last name
                    if ( !string.IsNullOrWhiteSpace( txtEmail.Text ) &&
                        !string.IsNullOrWhiteSpace( txtFirstName.Text ) &&
                        !string.IsNullOrWhiteSpace( txtLastName.Text ) )
                    {
                        // Same logic as CreatePledge.ascx.cs
                        var personMatches = personService.GetByMatch( txtFirstName.Text, txtLastName.Text, txtEmail.Text );
                        if ( personMatches.Count() == 1 )
                        {
                            person = personMatches.FirstOrDefault();
                        }
                        else
                        {
                            person = null;
                        }
                    }

                    if ( person == null )
                    {
                        DefinedValueCache dvcConnectionStatus = DefinedValueCache.Read( GetAttributeValue( "ConnectionStatus" ).AsGuid() );
                        DefinedValueCache dvcRecordStatus = DefinedValueCache.Read( GetAttributeValue( "RecordStatus" ).AsGuid() );

                        // Create Person
                        person = new Person();
                        person.FirstName = txtFirstName.Text;
                        person.LastName = txtLastName.Text;
                        person.IsEmailActive = true;
                        person.EmailPreference = EmailPreference.EmailAllowed;
                        person.RecordTypeValueId = DefinedValueCache.Read( Rock.SystemGuid.DefinedValue.PERSON_RECORD_TYPE_PERSON.AsGuid() ).Id;
                        if ( dvcConnectionStatus != null )
                        {
                            person.ConnectionStatusValueId = dvcConnectionStatus.Id;
                        }

                        if ( dvcRecordStatus != null )
                        {
                            person.RecordStatusValueId = dvcRecordStatus.Id;
                        }

                        // Create Person/Family
                        familyGroup = PersonService.SaveNewPerson( person, rockContext, null, false );
                    }

                    ViewState["PersonId"] = person != null ? person.Id : 0;
                }
            }

            if ( create && person != null ) // person should never be null at this point
            {
                person.Email = txtEmail.Text;

                if ( GetAttributeValue( "DisplayPhone" ).AsBooleanOrNull() ?? false )
                {
                    var numberTypeId = DefinedValueCache.Read( new Guid( Rock.SystemGuid.DefinedValue.PERSON_PHONE_TYPE_HOME ) ).Id;
                    var phone = person.PhoneNumbers.FirstOrDefault( p => p.NumberTypeValueId == numberTypeId );
                    if ( phone == null )
                    {
                        phone = new PhoneNumber();
                        person.PhoneNumbers.Add( phone );
                        phone.NumberTypeValueId = numberTypeId;
                    }
                    phone.CountryCode = PhoneNumber.CleanNumber( pnbPhone.CountryCode );
                    phone.Number = PhoneNumber.CleanNumber( pnbPhone.Number );
                }

                if ( familyGroup == null )
                {
                    var groupLocationService = new GroupLocationService( rockContext );
                    if ( GroupLocationId.HasValue )
                    {
                        familyGroup = groupLocationService.Queryable()
                            .Where( gl => gl.Id == GroupLocationId.Value )
//.........这里部分代码省略.........
开发者ID:NewSpring,项目名称:Rock,代码行数:101,代码来源:TransactionEntry.ascx.cs

示例13: fExceptionList_DisplayFilterValue

 /// <summary>
 /// Build filter values/summary with user friendly data from filters
 /// </summary>
 /// <param name="sender">The sender.</param>
 /// <param name="e">The e.</param>
 protected void fExceptionList_DisplayFilterValue( object sender, GridFilter.DisplayFilterValueArgs e )
 {
     switch ( e.Key )
     {
         case "Site":
             int siteId;
             if ( int.TryParse( e.Value, out siteId ) )
             {
                 var site = SiteCache.Read( siteId );
                 if ( site != null )
                 {
                     e.Value = site.Name;
                 }
             }
             break;
         case "Page":
             int pageId;
             if ( int.TryParse( e.Value, out pageId ) )
             {
                 var page = PageCache.Read( pageId );
                 if ( page != null )
                 {
                     e.Value = page.InternalName;
                 }
             }
             break;
         case "User":
             int userPersonId;
             if ( int.TryParse( e.Value, out userPersonId ) )
             {
                 PersonService personService = new PersonService( new RockContext() );
                 var user = personService.Get( userPersonId );
                 if ( user != null )
                 {
                     e.Value = user.FullName;
                 }
             }
             break;
     }
 }
开发者ID:CentralAZ,项目名称:Rockit-CentralAZ,代码行数:45,代码来源:ExceptionList.ascx.cs

示例14: gContentListFilter_DisplayFilterValue

        /// <summary>
        /// Handles the filter display for each saved user value
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The e.</param>
        /// <exception cref="System.NotImplementedException"></exception>
        protected void gContentListFilter_DisplayFilterValue( object sender, GridFilter.DisplayFilterValueArgs e )
        {
            switch ( e.Key )
            {
                case "Site":
                    e.Value = ddlSiteFilter.SelectedValue;
                    break;

                case "Approval Status":
                    e.Value = ddlApprovedFilter.SelectedValue;
                    break;

                case "Approved By":
                    int personId = 0;
                    if ( int.TryParse( e.Value, out personId ) && personId != 0 )
                    {
                        var personService = new PersonService( new RockContext() );
                        var person = personService.Get( personId );
                        if ( person != null )
                        {
                            e.Value = person.FullName;
                        }
                    }

                    break;
            }
        }
开发者ID:,项目名称:,代码行数:33,代码来源:

示例15: BindFilter

        /// <summary>
        /// Binds the filter.
        /// </summary>
        private void BindFilter()
        {
            var rockContext = new RockContext();

            var sites = new SiteService( rockContext ).Queryable().OrderBy( s => s.Name ).ToList();
            ddlSiteFilter.DataSource = sites;
            ddlSiteFilter.DataBind();
            ddlSiteFilter.Items.Insert( 0, Rock.Constants.All.ListItem );
            ddlSiteFilter.Visible = sites.Any();
            ddlSiteFilter.SetValue( gContentListFilter.GetUserPreference( "Site" ) );

            var item = ddlApprovedFilter.Items.FindByValue( gContentListFilter.GetUserPreference( "Approval Status" ) );
            if ( item != null )
            {
                item.Selected = true;
            }
            else
            {
                ddlApprovedFilter.SelectedIndex = 2;
            }

            int? personId = gContentListFilter.GetUserPreference( "Approved By" ).AsIntegerOrNull();
            if ( personId.HasValue )
            {
                var personService = new PersonService( rockContext );
                var person = personService.Get( personId.Value );
                if ( person != null )
                {
                    ppApprovedByFilter.SetValue( person );
                }
            }
        }
开发者ID:,项目名称:,代码行数:35,代码来源:


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