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


C# PersonAliasService.GetPerson方法代码示例

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


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

示例1: SavePersonNotes

        /// <summary>
        /// Saves the person notes.
        /// </summary>
        /// <param name="rockContext">The rock context.</param>
        /// <param name="previousRegistrantIds">The previous registrants.</param>
        /// <param name="registration">The registration.</param>
        private void SavePersonNotes( RockContext rockContext, List<int> previousRegistrantIds, Registration registration )
        {
            // Setup Note settings
            NoteTypeCache noteType = null;
            if ( RegistrationTemplate != null && RegistrationTemplate.AddPersonNote )
            {
                noteType = NoteTypeCache.Read( Rock.SystemGuid.NoteType.PERSON_EVENT_REGISTRATION.AsGuid() );
                if ( noteType != null )
                {
                    var noteService = new NoteService( rockContext );
                    var personAliasService = new PersonAliasService( rockContext );

                    Person registrar = null;
                    if ( registration.PersonAliasId.HasValue )
                    {
                        registrar = personAliasService.GetPerson( registration.PersonAliasId.Value );
                    }

                    var registrantNames = new List<string>();

                    // Get each registrant
                    foreach ( var registrantPersonAliasId in registration.Registrants
                        .Where( r => r.PersonAliasId.HasValue )
                        .Select( r => r.PersonAliasId.Value )
                        .ToList() )
                    {
                        var registrant = personAliasService.GetPerson( registrantPersonAliasId );
                        if ( registrant != null && !previousRegistrantIds.Contains( registrant.Id ) )
                        {
                            var noteText = new StringBuilder();
                            noteText.AppendFormat( "Registered for {0}", RegistrationInstanceState.Name );

                            if ( registrar != null && registrar.Id != registrant.Id )
                            {
                                noteText.AppendFormat( " by {0}", registrar.FullName );
                                registrantNames.Add( registrant.FullName );
                            }

                            if ( registrar != null && ( RegistrationState.FirstName != registrar.NickName || RegistrationState.LastName != registrar.LastName ) )
                            {
                                noteText.AppendFormat( " by {0}", RegistrationState.FirstName + " " + RegistrationState.LastName );
                            }

                            if ( noteText.Length > 0 )
                            {
                                var note = new Note();
                                note.NoteTypeId = noteType.Id;
                                note.IsSystem = false;
                                note.IsAlert = false;
                                note.IsPrivateNote = false;
                                note.EntityId = registrant.Id;
                                note.Caption = string.Empty;
                                note.Text = noteText.ToString();
                                noteService.Add( note );
                            }

                            var changes = new List<string> { "Registered for" };
                            HistoryService.SaveChanges(
                                rockContext,
                                typeof( Person ),
                                Rock.SystemGuid.Category.HISTORY_PERSON_REGISTRATION.AsGuid(),
                                registrant.Id,
                                changes,
                                RegistrationInstanceState.Name,
                                typeof( Registration ),
                                registration.Id,
                                false,
                                registration.PersonAliasId );
                        }
                    }

                    if ( registrar != null && registrantNames.Any() )
                    {
                        string namesText = string.Empty;
                        if ( registrantNames.Count >= 2 )
                        {
                            int lessOne = registrantNames.Count - 1;
                            namesText = registrantNames.Take( lessOne ).ToList().AsDelimited( ", " ) +
                                " and " +
                                registrantNames.Skip( lessOne ).Take( 1 ).First() + " ";
                        }
                        else
                        {
                            namesText = registrantNames.First() + " ";
                        }

                        var note = new Note();
                        note.NoteTypeId = noteType.Id;
                        note.IsSystem = false;
                        note.IsAlert = false;
                        note.IsPrivateNote = false;
                        note.EntityId = registrar.Id;
                        note.Caption = string.Empty;
                        note.Text = string.Format( "Registered {0} for {1}", namesText, RegistrationInstanceState.Name );
//.........这里部分代码省略.........
开发者ID:NewPointe,项目名称:Rockit,代码行数:101,代码来源:RegistrationEntry.ascx.cs

示例2: Execute

        /// <summary>
        /// Execute method to write transaction to the database.
        /// </summary>
        public void Execute()
        {
            using ( var rockContext = new RockContext() )
            {
                var documentService = new SignatureDocumentService( rockContext );
                var personAliasService = new PersonAliasService( rockContext );
                var appliesPerson = personAliasService.GetPerson( AppliesToPersonAliasId );
                var assignedPerson = personAliasService.GetPerson( AssignedToPersonAliasId );

                if ( !documentService.Queryable().Any( d =>
                        d.AppliesToPersonAliasId.HasValue &&
                        d.AppliesToPersonAliasId.Value == AppliesToPersonAliasId &&
                        d.Status == SignatureDocumentStatus.Signed ) )
                {
                    var documentTypeService = new SignatureDocumentTemplateService( rockContext );
                    var SignatureDocumentTemplate = documentTypeService.Get( SignatureDocumentTemplateId );

                    var errorMessages = new List<string>();
                    if ( documentTypeService.SendDocument( SignatureDocumentTemplate, appliesPerson, assignedPerson, DocumentName, Email, out errorMessages ) )
                    {
                        rockContext.SaveChanges();
                    }
                }
            }
        }
开发者ID:NewSpring,项目名称:Rock,代码行数:28,代码来源:SendDigitalSignatureRequestTransaction.cs


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