本文整理汇总了C#中Rock.Model.GroupTypeRoleService.Delete方法的典型用法代码示例。如果您正苦于以下问题:C# GroupTypeRoleService.Delete方法的具体用法?C# GroupTypeRoleService.Delete怎么用?C# GroupTypeRoleService.Delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rock.Model.GroupTypeRoleService
的用法示例。
在下文中一共展示了GroupTypeRoleService.Delete方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: btnSave_Click
/// <summary>
/// Handles the Click event of the btnSave control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
protected void btnSave_Click( object sender, EventArgs e )
{
GroupType groupType;
var rockContext = new RockContext();
GroupTypeService groupTypeService = new GroupTypeService( rockContext );
GroupTypeRoleService groupTypeRoleService = new GroupTypeRoleService( rockContext );
AttributeService attributeService = new AttributeService( rockContext );
AttributeQualifierService qualifierService = new AttributeQualifierService( rockContext );
CategoryService categoryService = new CategoryService( rockContext );
GroupScheduleExclusionService scheduleExclusionService = new GroupScheduleExclusionService( rockContext );
int groupTypeId = int.Parse( hfGroupTypeId.Value );
if ( groupTypeId == 0 )
{
groupType = new GroupType();
groupTypeService.Add( groupType );
}
else
{
groupType = groupTypeService.Get( groupTypeId );
// selected roles
var selectedRoleGuids = GroupTypeRolesState.Select( r => r.Guid );
foreach ( var role in groupType.Roles.Where( r => !selectedRoleGuids.Contains( r.Guid ) ).ToList() )
{
groupType.Roles.Remove( role );
groupTypeRoleService.Delete( role );
}
}
foreach ( var roleState in GroupTypeRolesState )
{
GroupTypeRole role = groupType.Roles.Where( r => r.Guid == roleState.Guid ).FirstOrDefault();
if ( role == null )
{
role = new GroupTypeRole();
groupType.Roles.Add( role );
}
else
{
roleState.Id = role.Id;
roleState.Guid = role.Guid;
}
role.CopyPropertiesFrom( roleState );
}
ScheduleType allowedScheduleTypes = ScheduleType.None;
foreach( ListItem li in cblScheduleTypes.Items )
{
if ( li.Selected )
{
allowedScheduleTypes = allowedScheduleTypes | (ScheduleType)li.Value.AsInteger();
}
}
GroupLocationPickerMode locationSelectionMode = GroupLocationPickerMode.None;
foreach ( ListItem li in cblLocationSelectionModes.Items )
{
if ( li.Selected )
{
locationSelectionMode = locationSelectionMode | (GroupLocationPickerMode)li.Value.AsInteger();
}
}
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.SendAttendanceReminder = cbSendAttendanceReminder.Checked;
groupType.AttendanceRule = ddlAttendanceRule.SelectedValueAsEnum<AttendanceRule>();
groupType.AttendancePrintTo = ddlPrintTo.SelectedValueAsEnum<PrintTo>();
groupType.AllowedScheduleTypes = allowedScheduleTypes;
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 );
}
}
//.........这里部分代码省略.........
示例2: btnSave_Click
/// <summary>
/// Handles the Click event of the btnSave control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
protected void btnSave_Click( object sender, EventArgs e )
{
GroupType groupType;
using ( new UnitOfWorkScope() )
{
GroupTypeService groupTypeService = new GroupTypeService();
GroupTypeRoleService groupTypeRoleService = new GroupTypeRoleService();
AttributeService attributeService = new AttributeService();
AttributeQualifierService qualifierService = new AttributeQualifierService();
CategoryService categoryService = new CategoryService();
int groupTypeId = int.Parse( hfGroupTypeId.Value );
if ( groupTypeId == 0 )
{
groupType = new GroupType();
groupTypeService.Add( groupType, CurrentPersonId );
}
else
{
groupType = groupTypeService.Get( groupTypeId );
// selected roles
var selectedRoleGuids = GroupTypeRolesState.Select( r => r.Guid );
foreach ( var role in groupType.Roles.Where( r => !selectedRoleGuids.Contains( r.Guid ) ).ToList() )
{
groupType.Roles.Remove( role );
groupTypeRoleService.Delete( role, CurrentPersonId );
}
}
foreach ( var roleState in GroupTypeRolesState )
{
GroupTypeRole role = groupType.Roles.Where( r => r.Guid == roleState.Guid ).FirstOrDefault();
if ( role == null )
{
role = new GroupTypeRole();
groupType.Roles.Add( role );
}
else
{
roleState.Id = role.Id;
roleState.Guid = role.Guid;
}
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 } );
}
//.........这里部分代码省略.........