本文整理汇总了C#中Rock.Model.GroupTypeRoleService.FirstOrDefault方法的典型用法代码示例。如果您正苦于以下问题:C# GroupTypeRoleService.FirstOrDefault方法的具体用法?C# GroupTypeRoleService.FirstOrDefault怎么用?C# GroupTypeRoleService.FirstOrDefault使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rock.Model.GroupTypeRoleService
的用法示例。
在下文中一共展示了GroupTypeRoleService.FirstOrDefault方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadViewState
/// <summary>
/// Restores the view-state information from a previous user control request that was saved by the <see cref="M:System.Web.UI.UserControl.SaveViewState" /> method.
/// </summary>
/// <param name="savedState">An <see cref="T:System.Object" /> that represents the user control state to be restored.</param>
protected override void LoadViewState( object savedState )
{
base.LoadViewState( savedState );
LocationTypeTab = ViewState["LocationTypeTab"] as string ?? MEMBER_LOCATION_TAB_TITLE;
CurrentGroupTypeId = ViewState["CurrentGroupTypeId"] as int? ?? 0;
// NOTE: These things are converted to JSON prior to going into ViewState, so the json variable could be null or the string "null"!
string json = ViewState["GroupLocationsState"] as string;
if ( string.IsNullOrWhiteSpace( json ) )
{
GroupLocationsState = new List<GroupLocation>();
}
else
{
GroupLocationsState = JsonConvert.DeserializeObject<List<GroupLocation>>( json );
}
json = ViewState["GroupMemberAttributesInheritedState"] as string;
if ( string.IsNullOrWhiteSpace( json ) )
{
GroupMemberAttributesInheritedState = new List<InheritedAttribute>();
}
else
{
GroupMemberAttributesInheritedState = JsonConvert.DeserializeObject<List<InheritedAttribute>>( json );
}
json = ViewState["GroupMemberAttributesState"] as string;
if ( string.IsNullOrWhiteSpace( json ) )
{
GroupMemberAttributesState = new List<Attribute>();
}
else
{
GroupMemberAttributesState = JsonConvert.DeserializeObject<List<Attribute>>( json );
}
json = ViewState["GroupRequirementsState"] as string;
if ( string.IsNullOrWhiteSpace( json ) )
{
GroupRequirementsState = new List<GroupRequirement>();
}
else
{
GroupRequirementsState = JsonConvert.DeserializeObject<List<GroupRequirement>>( json ) ?? new List<GroupRequirement>();
}
// get the GroupRole for each GroupRequirement from the database it case it isn't serialized, and we'll need it
var groupRoleIds = GroupRequirementsState.Where( a => a.GroupRoleId.HasValue && a.GroupRole == null ).Select( a => a.GroupRoleId.Value ).Distinct().ToList();
if ( groupRoleIds.Any() )
{
var groupRoles = new GroupTypeRoleService( new RockContext() ).GetByIds( groupRoleIds );
GroupRequirementsState.ForEach( a =>
{
if ( a.GroupRoleId.HasValue )
{
a.GroupRole = groupRoles.FirstOrDefault( b => b.Id == a.GroupRoleId );
}
} );
}
AllowMultipleLocations = ViewState["AllowMultipleLocations"] as bool? ?? false;
json = ViewState["MemberWorkflowTriggersState"] as string;
if ( string.IsNullOrWhiteSpace( json ) )
{
MemberWorkflowTriggersState = new List<GroupMemberWorkflowTrigger>();
}
else
{
MemberWorkflowTriggersState = JsonConvert.DeserializeObject<List<GroupMemberWorkflowTrigger>>( json );
}
}