本文整理汇总了C#中Rock.Model.GroupTypeService类的典型用法代码示例。如果您正苦于以下问题:C# GroupTypeService类的具体用法?C# GroupTypeService怎么用?C# GroupTypeService使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GroupTypeService类属于Rock.Model命名空间,在下文中一共展示了GroupTypeService类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShowDetail
/// <summary>
/// Shows the detail.
/// </summary>
/// <param name="groupTypeId">The groupType identifier.</param>
public void ShowDetail( int groupTypeId )
{
pnlDetails.Visible = false;
bool editAllowed = true;
GroupType groupType = null;
if ( !groupTypeId.Equals( 0 ) )
{
groupType = new GroupTypeService( new RockContext() ).Get( groupTypeId );
pdAuditDetails.SetEntity( groupType, ResolveRockUrl( "~" ) );
}
if ( groupType == null )
{
groupType = new GroupType { Id = 0 };
// hide the panel drawer that show created and last modified dates
pdAuditDetails.Visible = false;
}
if ( groupType != null )
{
editAllowed = groupType.IsAuthorized( Authorization.EDIT, CurrentPerson );
pnlDetails.Visible = true;
hfGroupTypeId.Value = groupType.Id.ToString();
// render UI based on Authorized and IsSystem
bool readOnly = false;
nbEditModeMessage.Text = string.Empty;
if ( !editAllowed || !IsUserAuthorized( Authorization.EDIT ) )
{
readOnly = true;
nbEditModeMessage.Text = EditModeMessage.ReadOnlyEditActionNotAllowed( GroupType.FriendlyTypeName );
}
if ( readOnly )
{
btnEdit.Visible = false;
btnDelete.Visible = false;
ShowReadonlyDetails( groupType );
}
else
{
btnEdit.Visible = true;
btnDelete.Visible = true;
if ( groupType.Id > 0 )
{
ShowReadonlyDetails( groupType );
}
else
{
ShowEditDetails( groupType );
}
}
}
}
示例2: 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 )
{
var rockContext = new RockContext();
GroupTypeService groupTypeService = new GroupTypeService( rockContext );
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;
}
groupType.ParentGroupTypes.Clear();
groupType.ChildGroupTypes.Clear();
groupTypeService.Delete( groupType );
rockContext.SaveChanges();
GroupTypeCache.Flush( groupTypeId );
}
BindGrid();
}
示例3: FormatValue
/// <summary>
/// Returns the field's current value(s)
/// </summary>
/// <param name="parentControl">The parent control.</param>
/// <param name="value">Information about the value</param>
/// <param name="configurationValues">The configuration values.</param>
/// <param name="condensed">Flag indicating if the value should be condensed (i.e. for use in a grid column)</param>
/// <returns></returns>
public override string FormatValue( Control parentControl, string value, Dictionary<string, ConfigurationValue> configurationValues, bool condensed )
{
string formattedValue = string.Empty;
string[] parts = ( value ?? string.Empty ).Split( '|' );
Guid? groupTypeGuid = parts[0].AsGuidOrNull();
Guid? groupGuid = parts[1].AsGuidOrNull();
var rockContext = new RockContext();
if ( groupGuid.HasValue )
{
var group = new GroupService( rockContext ).Get( groupGuid.Value );
if ( group != null )
{
formattedValue = "Group: " + group.Name;
}
}
else if ( groupTypeGuid.HasValue )
{
var groupType = new GroupTypeService( rockContext ).Get( groupTypeGuid.Value );
if ( groupType != null )
{
formattedValue = "Group type: " + groupType.Name;
}
}
return base.FormatValue( parentControl, formattedValue, null, condensed );
}
示例4: doCheckinGroupStuff
protected void doCheckinGroupStuff()
{
int checkinConfigFilter = int.TryParse(gtpCheckinConfig.SelectedValue, out checkinConfigFilter) ? checkinConfigFilter : -1;
int checkinAreaFilter = int.TryParse(gtpCheckinArea.SelectedValue, out checkinAreaFilter) ? checkinAreaFilter : -1;
int checkinGroupFilter = int.TryParse(rddlCheckinGroup.SelectedValue, out checkinGroupFilter) ? checkinGroupFilter : -1;
int groupTypePurposeCheckInTemplateId = DefinedValueCache.Read(new Guid(Rock.SystemGuid.DefinedValue.GROUPTYPE_PURPOSE_CHECKIN_TEMPLATE)).Id;
List<GroupType> checkinConfigs = new GroupTypeService(_rockContext).Queryable().Where(a => a.GroupTypePurposeValueId == groupTypePurposeCheckInTemplateId).OrderBy(a => a.ParentGroupTypes.FirstOrDefault().Id).ThenBy(a => a.Order).ThenBy(a => a.Name).ToList();
gtpCheckinConfig.GroupTypes = checkinConfigs;
if (gtpCheckinConfig.Items.FindByValue(checkinConfigFilter.ToString()) != null)
{
gtpCheckinConfig.SelectedValue = checkinConfigFilter.ToString();
}
gtpCheckinArea.GroupTypes = getCGT(checkinConfigs.Where(a => a.Id == gtpCheckinConfig.SelectedGroupTypeId).ToList(), "");
if (gtpCheckinArea.Items.FindByValue(checkinAreaFilter.ToString()) != null)
{
gtpCheckinArea.SelectedValue = checkinAreaFilter.ToString();
}
List<Rock.Model.Group> checkinGroups = new GroupService(_rockContext).Queryable().Where(a => a.GroupTypeId == gtpCheckinArea.SelectedGroupTypeId).OrderBy(a => a.Order).ThenBy(a => a.Name).ToList();
checkinGroups.Insert(0, new Rock.Model.Group() { Name = "", Id = -1 });
rddlCheckinGroup.DataSource = checkinGroups;
rddlCheckinGroup.DataTextField = "Name";
rddlCheckinGroup.DataValueField = "Id";
rddlCheckinGroup.DataBind();
if (rddlCheckinGroup.Items.FindByValue(checkinGroupFilter.ToString()) != null)
{
rddlCheckinGroup.SelectedValue = checkinGroupFilter.ToString();
}
}
示例5: EditControl
/// <summary>
/// Creates the control(s) neccessary for prompting user for a new value
/// </summary>
/// <param name="configurationValues">The configuration values.</param>
/// <returns>
/// The control
/// </returns>
public override System.Web.UI.Control EditControl( Dictionary<string, ConfigurationValue> configurationValues )
{
CheckBoxList editControl = new CheckBoxList();
GroupTypeService groupTypeService = new GroupTypeService();
var groupTypes = groupTypeService.Queryable().OrderBy( a => a.Name ).ToList();
foreach ( var groupType in groupTypes )
{
editControl.Items.Add(new ListItem(groupType.Name, groupType.Id.ToString()));
}
return editControl;
}
示例6: EditControl
/// <summary>
/// Creates the control(s) neccessary for prompting user for a new value
/// </summary>
/// <param name="configurationValues">The configuration values.</param>
/// <param name="id"></param>
/// <returns>
/// The control
/// </returns>
public override System.Web.UI.Control EditControl( Dictionary<string, ConfigurationValue> configurationValues, string id )
{
var editControl = new GroupTypePicker { ID = id };
var qryGroupTypes = new GroupTypeService( new RockContext() ).Queryable();
if ( configurationValues.ContainsKey( GROUP_TYPE_PURPOSE_VALUE_GUID ) )
{
var groupTypePurposeValueGuid = ( configurationValues[GROUP_TYPE_PURPOSE_VALUE_GUID] ).Value.AsGuidOrNull();
if ( groupTypePurposeValueGuid.HasValue )
{
qryGroupTypes = qryGroupTypes.Where( a => a.GroupTypePurposeValue.Guid == groupTypePurposeValueGuid.Value );
}
}
editControl.GroupTypes = qryGroupTypes.OrderBy( a => a.Name ).ToList();
return editControl;
}
示例7: GetInGroupOfType
public GroupOfTypeResult GetInGroupOfType(int personId, Guid groupTypeId)
{
GroupOfTypeResult result = new GroupOfTypeResult();
result.PersonId = personId;
result.PersonInGroup = false;
result.GroupList = new List<GroupSummary>();
// get person info
Person person = new PersonService( (Rock.Data.RockContext)Service.Context ).Get( personId );
if (person != null)
{
result.NickName = person.NickName;
result.LastName = person.LastName;
}
// get group type info
GroupType groupType = new GroupTypeService( (Rock.Data.RockContext)Service.Context ).Get( groupTypeId );
if (groupType != null)
{
result.GroupTypeName = groupType.Name;
result.GroupTypeIconCss = groupType.IconCssClass;
result.GroupTypeId = groupType.Id;
}
// determine if person is in this type of group
GroupMemberService groupMemberService = new GroupMemberService( (Rock.Data.RockContext)Service.Context );
IQueryable<GroupMember> groupMembershipsQuery = groupMemberService.Queryable("Person,GroupRole,Group")
.Where(t => t.Group.GroupType.Guid == groupTypeId && t.PersonId == personId )
.OrderBy(g => g.GroupRole.Order);
foreach (GroupMember member in groupMembershipsQuery)
{
result.PersonInGroup = true;
GroupSummary group = new GroupSummary();
group.GroupName = member.Group.Name;
group.GroupId = member.Group.Id;
group.RoleName = member.GroupRole.Name;
result.GroupList.Add(group);
}
return result;
}
示例8: ConfigurationControls
/// <summary>
/// Creates the HTML controls required to configure this type of field
/// </summary>
/// <returns></returns>
public override List<Control> ConfigurationControls()
{
var controls = base.ConfigurationControls();
// build a drop down list of defined types (the one that gets selected is
// used to build a list of defined values)
var ddl = new RockDropDownList();
controls.Add( ddl );
ddl.AutoPostBack = true;
ddl.SelectedIndexChanged += OnQualifierUpdated;
ddl.Label = "Group Type";
ddl.Help = "Type of group to select roles from, if left blank any group type's role can be selected.";
ddl.Items.Add( new ListItem() );
var groupTypeService = new GroupTypeService( new RockContext() );
var groupTypes = groupTypeService.Queryable().OrderBy( a => a.Name ).ToList();
groupTypes.ForEach( g =>
ddl.Items.Add( new ListItem( g.Name, g.Id.ToString().ToUpper() ) )
);
return controls;
}
示例9: ShowSettings
/// <summary>
/// Shows the settings.
/// </summary>
protected override void ShowSettings()
{
pnlEditModal.Visible = true;
upnlContent.Update();
mdEdit.Show();
var rockContext = new RockContext();
var groupTypes = new GroupTypeService( rockContext )
.Queryable().AsNoTracking().ToList();
BindGroupType( gtpGroupType, groupTypes, "GroupType" );
BindGroupType( gtpGeofenceGroupType, groupTypes, "GeofencedGroupType" );
string scheduleFilters = GetAttributeValue( "ScheduleFilters" );
if ( !string.IsNullOrEmpty( scheduleFilters ) )
{
foreach ( string val in scheduleFilters.SplitDelimitedValues() )
{
var li = cblSchedule.Items.FindByValue( val );
if ( li != null )
{
li.Selected = true;
}
}
}
SetGroupTypeOptions();
foreach ( string attr in GetAttributeValue( "AttributeFilters" ).SplitDelimitedValues() )
{
var li = cblAttributes.Items.FindByValue( attr );
if ( li != null )
{
li.Selected = true;
}
}
cbShowMap.Checked = GetAttributeValue( "ShowMap" ).AsBoolean();
ddlMapStyle.BindToDefinedType( DefinedTypeCache.Read( Rock.SystemGuid.DefinedType.MAP_STYLES.AsGuid() ) );
ddlMapStyle.SetValue( GetAttributeValue( "MapStyle" ) );
nbMapHeight.Text = GetAttributeValue( "MapHeight" );
cbShowFence.Checked = GetAttributeValue( "ShowFence" ).AsBoolean();
vlPolygonColors.Value = GetAttributeValue( "PolygonColors" );
ceMapInfo.Text = GetAttributeValue( "MapInfo" );
cbMapInfoDebug.Checked = GetAttributeValue( "MapInfoDebug" ).AsBoolean();
cbShowLavaOutput.Checked = GetAttributeValue( "ShowLavaOutput" ).AsBoolean();
ceLavaOutput.Text = GetAttributeValue( "LavaOutput" );
cbLavaOutputDebug.Checked = GetAttributeValue( "LavaOutputDebug" ).AsBoolean();
cbShowGrid.Checked = GetAttributeValue( "ShowGrid" ).AsBoolean();
cbShowSchedule.Checked = GetAttributeValue( "ShowSchedule" ).AsBoolean();
cbShowDescription.Checked = GetAttributeValue( "ShowDescription" ).AsBoolean();
cbProximity.Checked = GetAttributeValue( "ShowProximity" ).AsBoolean();
cbSortByDistance.Checked = GetAttributeValue( "SortByDistance" ).AsBoolean();
tbPageSizes.Text = GetAttributeValue( "PageSizes" );
cbShowCount.Checked = GetAttributeValue( "ShowCount" ).AsBoolean();
cbShowAge.Checked = GetAttributeValue( "ShowAge" ).AsBoolean();
foreach ( string attr in GetAttributeValue( "AttributeColumns" ).SplitDelimitedValues() )
{
var li = cblGridAttributes.Items.FindByValue( attr );
if ( li != null )
{
li.Selected = true;
}
}
var ppFieldType = new PageReferenceFieldType();
ppFieldType.SetEditValue( ppGroupDetailPage, null, GetAttributeValue( "GroupDetailPage" ) );
ppFieldType.SetEditValue( ppRegisterPage, null, GetAttributeValue( "RegisterPage" ) );
upnlContent.Update();
}
示例10: BindAttendeesGrid
/// <summary>
/// Binds the attendees grid.
/// </summary>
private void BindAttendeesGrid()
{
var dateRange = SlidingDateRangePicker.CalculateDateRangeFromDelimitedValues( drpSlidingDateRange.DelimitedValues );
if ( dateRange.End == null || dateRange.End > RockDateTime.Now )
{
dateRange.End = RockDateTime.Now;
}
var rockContext = new RockContext();
// make a qryPersonAlias so that the generated SQL will be a "WHERE .. IN ()" instead of an OUTER JOIN (which is incredibly slow for this)
var qryPersonAlias = new PersonAliasService( rockContext ).Queryable();
var qryAttendance = new AttendanceService( rockContext ).Queryable();
qryAttendance = qryAttendance.Where( a => a.DidAttend.HasValue && a.DidAttend.Value );
var groupType = this.GetSelectedTemplateGroupType();
var qryAllVisits = qryAttendance;
if ( groupType != null )
{
var childGroupTypeIds = new GroupTypeService( rockContext ).GetChildGroupTypes( groupType.Id ).Select( a => a.Id );
qryAllVisits = qryAttendance.Where( a => childGroupTypeIds.Any( b => b == a.Group.GroupTypeId ) );
}
else
{
return;
}
var groupIdList = new List<int>();
string groupIds = GetSelectedGroupIds().AsDelimited( "," );
if ( !string.IsNullOrWhiteSpace( groupIds ) )
{
groupIdList = groupIds.Split( ',' ).AsIntegerList();
qryAttendance = qryAttendance.Where( a => a.GroupId.HasValue && groupIdList.Contains( a.GroupId.Value ) );
}
//// If campuses were included, filter attendances by those that have selected campuses
//// if 'null' is one of the campuses, treat that as a 'CampusId is Null'
var includeNullCampus = clbCampuses.SelectedValues.Any( a => a.Equals( "null", StringComparison.OrdinalIgnoreCase ) );
var campusIdList = clbCampuses.SelectedValues.AsIntegerList();
// remove 0 from the list, just in case it is there
campusIdList.Remove( 0 );
if ( campusIdList.Any() )
{
if ( includeNullCampus )
{
// show records that have a campusId in the campusIdsList + records that have a null campusId
qryAttendance = qryAttendance.Where( a => ( a.CampusId.HasValue && campusIdList.Contains( a.CampusId.Value ) ) || !a.CampusId.HasValue );
}
else
{
// only show records that have a campusId in the campusIdList
qryAttendance = qryAttendance.Where( a => a.CampusId.HasValue && campusIdList.Contains( a.CampusId.Value ) );
}
}
else if ( includeNullCampus )
{
// 'null' was the only campusId in the campusIds parameter, so only show records that have a null CampusId
qryAttendance = qryAttendance.Where( a => !a.CampusId.HasValue );
}
// have the "Missed" query be the same as the qry before the Main date range is applied since it'll have a different date range
var qryMissed = qryAttendance;
if ( dateRange.Start.HasValue )
{
qryAttendance = qryAttendance.Where( a => a.StartDateTime >= dateRange.Start.Value );
}
if ( dateRange.End.HasValue )
{
qryAttendance = qryAttendance.Where( a => a.StartDateTime < dateRange.End.Value );
}
// we want to get the first 2 visits at a minimum so we can show the date in the grid
int nthVisitsTake = 2;
int? byNthVisit = null;
if ( radByVisit.Checked )
{
// If we are filtering by nth visit, we might want to get up to first 5
byNthVisit = ddlNthVisit.SelectedValue.AsIntegerOrNull();
if ( byNthVisit.HasValue && byNthVisit > 2 )
{
nthVisitsTake = byNthVisit.Value;
}
}
ChartGroupBy groupBy = hfGroupBy.Value.ConvertToEnumOrNull<ChartGroupBy>() ?? ChartGroupBy.Week;
IQueryable<PersonWithSummary> qryByPersonWithSummary = null;
if ( byNthVisit.HasValue && byNthVisit.Value == 0 )
{
// Show members of the selected groups that did not attend at all during selected date range
//.........这里部分代码省略.........
示例11: BuildGroupTypesUI
/// <summary>
/// Builds the group types UI
/// </summary>
private void BuildGroupTypesUI()
{
var groupType = this.GetSelectedTemplateGroupType();
if ( groupType != null )
{
nbGroupTypeWarning.Visible = false;
var groupTypes = new GroupTypeService( _rockContext ).GetChildGroupTypes( groupType.Id ).OrderBy( a => a.Order ).ThenBy( a => a.Name );
// only add each group type once in case the group type is a child of multiple parents
_addedGroupTypeIds = new List<int>();
rptGroupTypes.DataSource = groupTypes.ToList();
rptGroupTypes.DataBind();
}
else
{
nbGroupTypeWarning.Text = "Please select a check-in type.";
nbGroupTypeWarning.Visible = true;
}
}
示例12: 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 );
}
}
//.........这里部分代码省略.........
示例13: GetBreadCrumbs
/// <summary>
/// Returns breadcrumbs specific to the block that should be added to navigation
/// based on the current page reference. This function is called during the page's
/// oninit to load any initial breadcrumbs
/// </summary>
/// <param name="pageReference">The page reference.</param>
/// <returns></returns>
public override List<BreadCrumb> GetBreadCrumbs( PageReference pageReference )
{
var breadCrumbs = new List<BreadCrumb>();
int? groupTypeId = PageParameter( pageReference, "groupTypeId" ).AsIntegerOrNull();
if ( groupTypeId != null )
{
GroupType groupType = new GroupTypeService( new RockContext() ).Get( groupTypeId.Value );
if ( groupType != null )
{
breadCrumbs.Add( new BreadCrumb( groupType.Name, pageReference ) );
}
else
{
breadCrumbs.Add( new BreadCrumb( "New Group Type", pageReference ) );
}
}
else
{
// don't show a breadcrumb if we don't have a pageparam to work with
}
return breadCrumbs;
}
示例14: BindInheritedAttributes
/// <summary>
/// Binds the inherited attributes.
/// </summary>
/// <param name="inheritedGroupTypeId">The inherited group type identifier.</param>
/// <param name="groupTypeService">The group type service.</param>
/// <param name="attributeService">The attribute service.</param>
private void BindInheritedAttributes( int? inheritedGroupTypeId, GroupTypeService groupTypeService, AttributeService attributeService )
{
GroupTypeAttributesInheritedState = new List<InheritedAttribute>();
GroupAttributesInheritedState = new List<InheritedAttribute>();
GroupMemberAttributesInheritedState = new List<InheritedAttribute>();
while ( inheritedGroupTypeId.HasValue )
{
var inheritedGroupType = groupTypeService.Get( inheritedGroupTypeId.Value );
if ( inheritedGroupType != null )
{
string qualifierValue = inheritedGroupType.Id.ToString();
foreach ( var attribute in attributeService.GetByEntityTypeId( new GroupType().TypeId ).AsQueryable()
.Where( a =>
a.EntityTypeQualifierColumn.Equals( "Id", StringComparison.OrdinalIgnoreCase ) &&
a.EntityTypeQualifierValue.Equals( qualifierValue ) )
.OrderBy( a => a.Order )
.ThenBy( a => a.Name )
.ToList() )
{
GroupTypeAttributesInheritedState.Add( new InheritedAttribute(
attribute.Name,
attribute.Key,
attribute.Description,
Page.ResolveUrl( "~/GroupType/" + attribute.EntityTypeQualifierValue ),
inheritedGroupType.Name ) );
}
foreach ( var attribute in attributeService.GetByEntityTypeId( new Group().TypeId ).AsQueryable()
.Where( a =>
a.EntityTypeQualifierColumn.Equals( "GroupTypeId", StringComparison.OrdinalIgnoreCase ) &&
a.EntityTypeQualifierValue.Equals( qualifierValue ) )
.OrderBy( a => a.Order )
.ThenBy( a => a.Name )
.ToList() )
{
GroupAttributesInheritedState.Add( new InheritedAttribute(
attribute.Name,
attribute.Key,
attribute.Description,
Page.ResolveUrl( "~/GroupType/" + attribute.EntityTypeQualifierValue ),
inheritedGroupType.Name ) );
}
foreach ( var attribute in attributeService.GetByEntityTypeId( new GroupMember().TypeId ).AsQueryable()
.Where( a =>
a.EntityTypeQualifierColumn.Equals( "GroupTypeId", StringComparison.OrdinalIgnoreCase ) &&
a.EntityTypeQualifierValue.Equals( qualifierValue ) )
.OrderBy( a => a.Order )
.ThenBy( a => a.Name )
.ToList() )
{
GroupMemberAttributesInheritedState.Add( new InheritedAttribute(
attribute.Name,
attribute.Key,
attribute.Description,
Page.ResolveUrl( "~/GroupType/" + attribute.EntityTypeQualifierValue ),
inheritedGroupType.Name ) );
}
inheritedGroupTypeId = inheritedGroupType.InheritedGroupTypeId;
}
else
{
inheritedGroupTypeId = null;
}
}
BindGroupTypeAttributesInheritedGrid();
BindGroupAttributesInheritedGrid();
BindGroupMemberAttributesInheritedGrid();
}
示例15: 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 )
{
using ( var rockContext = new RockContext() )
{
var groupTypeService = new GroupTypeService( rockContext );
GroupType groupType;
if ( hfGroupTypeId.Value.AsInteger() == 0 )
{
groupType = new GroupType();
groupTypeService.Add( groupType );
groupType.GroupTypePurposeValueId = DefinedValueCache.Read( Rock.SystemGuid.DefinedValue.GROUPTYPE_PURPOSE_CHECKIN_TEMPLATE ).Id;
groupType.ShowInNavigation = false;
groupType.ShowInGroupList = false;
}
else
{
groupType = groupTypeService.Get( hfGroupTypeId.Value.AsInteger() );
}
groupType.Name = tbGroupTypeName.Text;
groupType.Description = tbGroupTypeDescription.Text;
rockContext.SaveChanges();
}
mdAddEditCheckinGroupType.Hide();
BindGrid();
}