本文整理汇总了C#中Rock.Model.GroupTypeRoleService.GetByGroupTypeId方法的典型用法代码示例。如果您正苦于以下问题:C# GroupTypeRoleService.GetByGroupTypeId方法的具体用法?C# GroupTypeRoleService.GetByGroupTypeId怎么用?C# GroupTypeRoleService.GetByGroupTypeId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rock.Model.GroupTypeRoleService
的用法示例。
在下文中一共展示了GroupTypeRoleService.GetByGroupTypeId方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: btnSave_Click
//.........这里部分代码省略.........
groupType.LocationSelectionMode = locationSelectionMode;
groupType.GroupTypePurposeValueId = ddlGroupTypePurpose.SelectedValueAsInt();
groupType.AllowMultipleLocations = cbAllowMultipleLocations.Checked;
groupType.InheritedGroupTypeId = gtpInheritedGroupType.SelectedGroupTypeId;
groupType.EnableLocationSchedules = cbEnableLocationSchedules.Checked;
groupType.ChildGroupTypes = new List<GroupType>();
groupType.ChildGroupTypes.Clear();
foreach ( var item in ChildGroupTypesDictionary )
{
var childGroupType = groupTypeService.Get( item.Key );
if ( childGroupType != null )
{
groupType.ChildGroupTypes.Add( childGroupType );
}
}
// Delete any removed exclusions
foreach ( var exclusion in groupType.GroupScheduleExclusions.Where( s => !ScheduleExclusionDictionary.Keys.Contains( s.Guid ) ).ToList() )
{
groupType.GroupScheduleExclusions.Remove( exclusion );
scheduleExclusionService.Delete( exclusion );
}
// Update exclusions
foreach( var keyVal in ScheduleExclusionDictionary )
{
var scheduleExclusion = groupType.GroupScheduleExclusions
.FirstOrDefault( s => s.Guid.Equals( keyVal.Key));
if ( scheduleExclusion == null )
{
scheduleExclusion = new GroupScheduleExclusion();
groupType.GroupScheduleExclusions.Add( scheduleExclusion);
}
scheduleExclusion.StartDate = keyVal.Value.Start;
scheduleExclusion.EndDate = keyVal.Value.End;
}
DefinedValueService definedValueService = new DefinedValueService( rockContext );
groupType.LocationTypes = new List<GroupTypeLocationType>();
groupType.LocationTypes.Clear();
foreach ( var item in LocationTypesDictionary )
{
var locationType = definedValueService.Get( item.Key );
if ( locationType != null )
{
groupType.LocationTypes.Add( new GroupTypeLocationType { LocationTypeValueId = locationType.Id } );
}
}
if ( !groupType.IsValid )
{
// Controls will render the error messages
return;
}
// need WrapTransaction due to Attribute saves
rockContext.WrapTransaction( () =>
{
rockContext.SaveChanges();
/* Save Attributes */
string qualifierValue = groupType.Id.ToString();
SaveAttributes( new GroupType().TypeId, "Id", qualifierValue, GroupTypeAttributesState, rockContext );
SaveAttributes( new Group().TypeId, "GroupTypeId", qualifierValue, GroupAttributesState, rockContext );
SaveAttributes( new GroupMember().TypeId, "GroupTypeId", qualifierValue, GroupMemberAttributesState, rockContext );
// Reload to save default role
groupType = groupTypeService.Get( groupType.Id );
groupType.DefaultGroupRole = groupType.Roles.FirstOrDefault( r => r.Guid.Equals( DefaultRoleGuid ) );
if ( groupType.DefaultGroupRole == null )
{
groupType.DefaultGroupRole = groupType.Roles.FirstOrDefault();
}
rockContext.SaveChanges();
// Reload the roles and apply their attribute values
foreach ( var role in groupTypeRoleService.GetByGroupTypeId( groupType.Id ).ToList() )
{
role.LoadAttributes( rockContext );
var roleState = GroupTypeRolesState.Where( r => r.Guid.Equals( role.Guid ) ).FirstOrDefault();
if ( roleState != null && roleState.AttributeValues != null )
{
foreach ( var attributeValue in roleState.AttributeValues )
{
role.SetAttributeValue( attributeValue.Key, roleState.GetAttributeValue( attributeValue.Key ) );
}
role.SaveAttributeValues( rockContext );
}
}
} );
GroupTypeCache.Flush( groupType.Id );
NavigateToParentPage();
}
示例2: btnSave_Click
//.........这里部分代码省略.........
role.CopyPropertiesFrom( roleState );
}
GroupLocationPickerMode locationSelectionMode = GroupLocationPickerMode.None;
foreach(ListItem li in cblLocationSelectionModes.Items)
{
if ( li.Selected )
{
locationSelectionMode = locationSelectionMode | (GroupLocationPickerMode)li.Value.AsInteger().Value;
}
}
groupType.Name = tbName.Text;
groupType.Description = tbDescription.Text;
groupType.GroupTerm = tbGroupTerm.Text;
groupType.GroupMemberTerm = tbGroupMemberTerm.Text;
groupType.ShowInGroupList = cbShowInGroupList.Checked;
groupType.ShowInNavigation = cbShowInNavigation.Checked;
groupType.IconCssClass = tbIconCssClass.Text;
groupType.TakesAttendance = cbTakesAttendance.Checked;
groupType.AttendanceRule = ddlAttendanceRule.SelectedValueAsEnum<AttendanceRule>();
groupType.AttendancePrintTo = ddlAttendancePrintTo.SelectedValueAsEnum<PrintTo>();
groupType.LocationSelectionMode = locationSelectionMode;
groupType.GroupTypePurposeValueId = ddlGroupTypePurpose.SelectedValueAsInt();
groupType.AllowMultipleLocations = cbAllowMultipleLocations.Checked;
groupType.InheritedGroupTypeId = gtpInheritedGroupType.SelectedGroupTypeId;
groupType.ChildGroupTypes = new List<GroupType>();
groupType.ChildGroupTypes.Clear();
foreach ( var item in ChildGroupTypesDictionary )
{
var childGroupType = groupTypeService.Get( item.Key );
if ( childGroupType != null )
{
groupType.ChildGroupTypes.Add( childGroupType );
}
}
DefinedValueService definedValueService = new DefinedValueService();
groupType.LocationTypes = new List<GroupTypeLocationType>();
groupType.LocationTypes.Clear();
foreach ( var item in LocationTypesDictionary )
{
var locationType = definedValueService.Get( item.Key );
if ( locationType != null )
{
groupType.LocationTypes.Add( new GroupTypeLocationType { LocationTypeValueId = locationType.Id } );
}
}
if ( !groupType.IsValid )
{
// Controls will render the error messages
return;
}
RockTransactionScope.WrapTransaction( () =>
{
groupTypeService.Save( groupType, CurrentPersonId );
/* Save Attributes */
string qualifierValue = groupType.Id.ToString();
SaveAttributes( new GroupType().TypeId, "Id", qualifierValue, GroupTypeAttributesState, attributeService, qualifierService, categoryService );
SaveAttributes( new Group().TypeId, "GroupTypeId", qualifierValue, GroupAttributesState, attributeService, qualifierService, categoryService );
SaveAttributes( new GroupMember().TypeId, "GroupTypeId", qualifierValue, GroupMemberAttributesState, attributeService, qualifierService, categoryService );
// Reload to save default role
groupType = groupTypeService.Get( groupType.Id );
groupType.DefaultGroupRole = groupType.Roles.FirstOrDefault( r => r.Guid.Equals( DefaultRoleGuid ) );
if ( groupType.DefaultGroupRole == null )
{
groupType.DefaultGroupRole = groupType.Roles.FirstOrDefault();
}
groupTypeService.Save( groupType, CurrentPersonId );
// Reload the roles and apply their attribute values
foreach ( var role in groupTypeRoleService.GetByGroupTypeId( groupType.Id ) )
{
role.LoadAttributes();
var roleState = GroupTypeRolesState.Where( r => r.Guid.Equals( role.Guid ) ).FirstOrDefault();
if ( roleState != null && roleState.AttributeValues != null )
{
foreach ( var attributeValue in roleState.AttributeValues )
{
role.SetAttributeValue( attributeValue.Key, roleState.GetAttributeValue( attributeValue.Key ) );
}
Helper.SaveAttributeValues( role, CurrentPersonId );
}
}
} );
GroupTypeCache.Flush( groupType.Id );
}
NavigateToParentPage();
}