本文整理汇总了C#中Rock.Model.PersonService.Any方法的典型用法代码示例。如果您正苦于以下问题:C# PersonService.Any方法的具体用法?C# PersonService.Any怎么用?C# PersonService.Any使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rock.Model.PersonService
的用法示例。
在下文中一共展示了PersonService.Any方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateEmailCommunication
/// <summary>
/// Creates the email communication.
/// </summary>
/// <param name="recipientEmails">The recipient emails.</param>
/// <param name="fromName">From name.</param>
/// <param name="fromAddress">From address.</param>
/// <param name="replyTo">The reply to.</param>
/// <param name="subject">The subject.</param>
/// <param name="htmlMessage">The HTML message.</param>
/// <param name="textMessage">The text message.</param>
/// <param name="bulkCommunication">if set to <c>true</c> [bulk communication].</param>
/// <param name="recipientStatus">The recipient status.</param>
/// <param name="senderPersonAliasId">The sender person alias identifier.</param>
/// <returns></returns>
public Communication CreateEmailCommunication(
List<string> recipientEmails,
string fromName,
string fromAddress,
string replyTo,
string subject,
string htmlMessage,
string textMessage,
bool bulkCommunication,
CommunicationRecipientStatus recipientStatus = CommunicationRecipientStatus.Delivered,
int? senderPersonAliasId = null )
{
var recipients = new PersonService( (RockContext)this.Context )
.Queryable()
.Where( p => recipientEmails.Contains( p.Email ) )
.ToList();
if ( recipients.Any() )
{
Rock.Model.Communication communication = new Rock.Model.Communication();
communication.Status = CommunicationStatus.Approved;
communication.SenderPersonAliasId = senderPersonAliasId;
communication.Subject = subject;
Add( communication );
communication.IsBulkCommunication = bulkCommunication;
communication.MediumEntityTypeId = EntityTypeCache.Read( "Rock.Communication.Medium.Email" ).Id;
communication.FutureSendDateTime = null;
// add each person as a recipient to the communication
foreach ( var person in recipients )
{
int? personAliasId = person.PrimaryAliasId;
if ( personAliasId.HasValue )
{
var communicationRecipient = new CommunicationRecipient();
communicationRecipient.PersonAliasId = personAliasId.Value;
communicationRecipient.Status = recipientStatus;
communication.Recipients.Add( communicationRecipient );
}
}
// add the MediumData to the communication
communication.MediumData.Clear();
communication.MediumData.Add( "FromName", fromName );
communication.MediumData.Add( "FromAddress", fromAddress );
communication.MediumData.Add( "ReplyTo", replyTo );
communication.MediumData.Add( "Subject", subject );
communication.MediumData.Add( "HtmlMessage", htmlMessage );
communication.MediumData.Add( "TextMessage", textMessage );
return communication;
}
return null;
}