本文整理汇总了C#中Rock.Model.GroupTypeService.Save方法的典型用法代码示例。如果您正苦于以下问题:C# GroupTypeService.Save方法的具体用法?C# GroupTypeService.Save怎么用?C# GroupTypeService.Save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rock.Model.GroupTypeService
的用法示例。
在下文中一共展示了GroupTypeService.Save方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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 )
{
bool hasValidationErrors = false;
using ( new UnitOfWorkScope() )
{
GroupTypeService groupTypeService = new GroupTypeService();
GroupService groupService = new GroupService();
AttributeService attributeService = new AttributeService();
int parentGroupTypeId = hfParentGroupTypeId.ValueAsInt();
var groupTypeUIList = new List<GroupType>();
foreach ( var checkinGroupTypeEditor in phCheckinGroupTypes.Controls.OfType<CheckinGroupTypeEditor>().ToList() )
{
var groupType = checkinGroupTypeEditor.GetCheckinGroupType();
groupTypeUIList.Add( groupType );
}
var groupTypeDBList = new List<GroupType>();
var groupTypesToDelete = new List<GroupType>();
var groupsToDelete = new List<Group>();
var groupTypesToAddUpdate = new List<GroupType>();
var groupsToAddUpdate = new List<Group>();
GroupType parentGroupTypeDB = groupTypeService.Get( parentGroupTypeId );
GroupType parentGroupTypeUI = parentGroupTypeDB.Clone( false );
parentGroupTypeUI.ChildGroupTypes = groupTypeUIList;
PopulateDeleteLists( groupTypesToDelete, groupsToDelete, parentGroupTypeDB, parentGroupTypeUI );
PopulateAddUpdateLists( groupTypesToAddUpdate, groupsToAddUpdate, parentGroupTypeUI );
int binaryFileFieldTypeID = new FieldTypeService().Get( new Guid( Rock.SystemGuid.FieldType.BINARY_FILE ) ).Id;
int binaryFileTypeId = new BinaryFileTypeService().Get( new Guid( Rock.SystemGuid.BinaryFiletype.CHECKIN_LABEL ) ).Id;
RockTransactionScope.WrapTransaction( () =>
{
// delete in reverse order to get deepest child items first
groupsToDelete.Reverse();
foreach ( var groupToDelete in groupsToDelete )
{
groupService.Delete( groupToDelete, this.CurrentPersonId );
groupService.Save( groupToDelete, this.CurrentPersonId );
}
// delete in reverse order to get deepest child items first
groupTypesToDelete.Reverse();
foreach ( var groupTypeToDelete in groupTypesToDelete )
{
groupTypeService.Delete( groupTypeToDelete, this.CurrentPersonId );
groupTypeService.Save( groupTypeToDelete, this.CurrentPersonId );
}
// Add/Update grouptypes and groups that are in the UI
// Note: We'll have to save all the groupTypes without changing the DB value of ChildGroupTypes, then come around again and save the ChildGroupTypes
// since the ChildGroupTypes may not exist in the database yet
foreach ( GroupType groupTypeUI in groupTypesToAddUpdate )
{
GroupType groupTypeDB = groupTypeService.Get( groupTypeUI.Guid );
if ( groupTypeDB == null )
{
groupTypeDB = new GroupType();
groupTypeDB.Id = 0;
groupTypeDB.Guid = groupTypeUI.Guid;
}
groupTypeDB.Name = groupTypeUI.Name;
groupTypeDB.Order = groupTypeUI.Order;
groupTypeDB.InheritedGroupTypeId = groupTypeUI.InheritedGroupTypeId;
groupTypeDB.Attributes = groupTypeUI.Attributes;
groupTypeDB.AttributeValues = groupTypeUI.AttributeValues;
if ( groupTypeDB.Id == 0 )
{
groupTypeService.Add( groupTypeDB, this.CurrentPersonId );
}
if ( !groupTypeDB.IsValid )
{
hasValidationErrors = true;
CheckinGroupTypeEditor groupTypeEditor = phCheckinGroupTypes.ControlsOfTypeRecursive<CheckinGroupTypeEditor>().First( a => a.GroupTypeGuid == groupTypeDB.Guid );
groupTypeEditor.ForceContentVisible = true;
return;
}
groupTypeService.Save( groupTypeDB, this.CurrentPersonId );
Rock.Attribute.Helper.SaveAttributeValues( groupTypeDB, this.CurrentPersonId );
// get fresh from database to make sure we have Id so we can update the CheckinLabel Attributes
//.........这里部分代码省略.........
示例2: mdAddCheckinGroupType_SaveClick
/// <summary>
/// Handles the SaveClick event of the mdAddCheckinGroupType 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 mdAddCheckinGroupType_SaveClick( object sender, EventArgs e )
{
var groupTypeService = new GroupTypeService();
GroupType groupType = new GroupType();
groupType.Name = tbGroupTypeName.Text;
groupType.GroupTypePurposeValueId = DefinedValueCache.Read( Rock.SystemGuid.DefinedValue.GROUPTYPE_PURPOSE_CHECKIN_TEMPLATE ).Id;
groupType.ShowInNavigation = false;
groupType.ShowInGroupList = false;
groupTypeService.Add( groupType, this.CurrentPersonId );
groupTypeService.Save( groupType, this.CurrentPersonId );
mdAddCheckinGroupType.Hide();
BindGrid();
}
示例3: 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 } );
}
//.........这里部分代码省略.........
示例4: gGroupType_Delete
/// <summary>
/// Handles the Delete event of the gGroupType control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="RowEventArgs" /> instance containing the event data.</param>
protected void gGroupType_Delete( object sender, RowEventArgs e )
{
RockTransactionScope.WrapTransaction( () =>
{
GroupTypeService groupTypeService = new GroupTypeService();
GroupType groupType = groupTypeService.Get( e.RowKeyId );
if ( groupType != null )
{
int groupTypeId = groupType.Id;
if ( !groupType.IsAuthorized("Administrate", CurrentPerson))
{
mdGridWarning.Show( "Sorry, you're not authorized to delete this group type.", ModalAlertType.Alert );
return;
}
string errorMessage;
if ( !groupTypeService.CanDelete( groupType, out errorMessage ) )
{
mdGridWarning.Show( errorMessage, ModalAlertType.Alert );
return;
}
groupTypeService.Delete( groupType, CurrentPersonId );
groupTypeService.Save( groupType, CurrentPersonId );
GroupTypeCache.Flush( groupTypeId );
}
} );
BindGrid();
}