本文整理汇总了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 );
//.........这里部分代码省略.........
示例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();
}
}
}
}