本文整理汇总了C#中Rock.Model.GroupMemberService.First方法的典型用法代码示例。如果您正苦于以下问题:C# GroupMemberService.First方法的具体用法?C# GroupMemberService.First怎么用?C# GroupMemberService.First使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rock.Model.GroupMemberService
的用法示例。
在下文中一共展示了GroupMemberService.First方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShowForm
/// <summary>
/// Shows the view.
/// </summary>
private void ShowForm()
{
lReceipt.Visible = false;
pnlAddPledge.Visible = true;
if ( CurrentPerson != null )
{
lName.Text = CurrentPerson.FullName;
lName.Visible = true;
tbFirstName.Visible = false;
tbLastName.Visible = false;
tbEmail.Visible = false;
using ( var rockContext = new RockContext() )
{
Guid? groupTypeGuid = GetAttributeValue( "SelectGroupType" ).AsGuidOrNull();
if ( groupTypeGuid.HasValue )
{
var groups = new GroupMemberService( rockContext )
.Queryable().AsNoTracking()
.Where( m =>
m.Group.GroupType.Guid == groupTypeGuid.Value &&
m.PersonId == CurrentPerson.Id &&
m.GroupMemberStatus == GroupMemberStatus.Active &&
m.Group.IsActive )
.Select( m => new
{
m.GroupId,
Name = m.Group.Name,
GroupTypeName = m.Group.GroupType.Name
} )
.ToList()
.Distinct()
.OrderBy( g => g.Name )
.ToList();
if ( groups.Any() )
{
ddlGroup.Label = "For " + groups.First().GroupTypeName;
ddlGroup.DataSource = groups;
ddlGroup.DataBind();
ddlGroup.Visible = true;
}
else
{
ddlGroup.Visible = false;
}
}
else
{
ddlGroup.Visible = false;
}
}
}
else
{
lName.Visible = false;
ddlGroup.Visible = false;
tbFirstName.Visible = true;
tbLastName.Visible = true;
tbEmail.Visible = true;
tbFirstName.Text = string.Empty;
tbLastName.Text = string.Empty;
tbEmail.Text = string.Empty;
}
// Warn if Financial Account is not specified (must be set up by administrator)
var financialAccount = new FinancialAccountService( new RockContext() ).Get( GetAttributeValue( "Account" ).AsGuid() );
if ( financialAccount == null )
{
nbWarningMessage.Text = "Warning: No Account is specified for this pledge. Please contact the administrator.";
nbWarningMessage.Visible = true;
}
else
{
nbWarningMessage.Visible = false;
}
drpDateRange.DelimitedValues = GetAttributeValue( "PledgeDateRange" );
// only show the date range picker if the block setting for date range isn't fully specified
drpDateRange.Visible = drpDateRange.LowerValue == null || drpDateRange.UpperValue == null;
ddlFrequency.Items.Clear();
var frequencies = DefinedTypeCache.Read( Rock.SystemGuid.DefinedType.FINANCIAL_FREQUENCY.AsGuid() ).DefinedValues.OrderBy( a => a.Order ).ThenBy( a => a.Value );
foreach ( var frequency in frequencies )
{
ddlFrequency.Items.Add( new ListItem( frequency.Value, frequency.Id.ToString() ) );
}
ddlFrequency.Visible = GetAttributeValue( "ShowPledgeFrequency" ).AsBooleanOrNull() ?? false;
ddlFrequency.SelectedValue = null;
// if Frequency is Visible, require it if RequirePledgeFrequency
ddlFrequency.Required = ddlFrequency.Visible && ( GetAttributeValue( "RequirePledgeFrequency" ).AsBooleanOrNull() ?? false );
//.........这里部分代码省略.........