/// <summary> /// Gets the entity object given it's type. /// </summary> /// <typeparam name="T">The IEntity type to retrieve.</typeparam> /// <returns>A reference to the IEntity object or null if none was found.</returns> public virtual T GetContextEntity <T>() where T : IEntity { if (ContextEntities.ContainsKey(typeof(T))) { return(( T )ContextEntities[typeof(T)].Value); } return(default);
/// <summary> /// Gets the entity object given it's type. /// </summary> /// <returns>A reference to the IEntity object or null if none was found.</returns> public virtual IEntity GetContextEntity(Type entityType) { if (ContextEntities.ContainsKey(entityType)) { return(ContextEntities[entityType].Value); } return(default);
/// <summary> /// Raises the <see cref="E:System.Web.UI.Control.Init" /> event. /// </summary> /// <param name="e">An <see cref="T:System.EventArgs" /> object that contains the event data.</param> protected override void OnInit(EventArgs e) { base.OnInit(e); if (ContextEntities.ContainsKey("Rock.Model.Person")) { Person = ContextEntities["Rock.Model.Person"] as Person; if (Person == null) { Person = new Person(); } } }
/// <summary> /// Binds the grid. /// </summary> private void BindGrid() { GroupService groupService = new GroupService(); SortProperty sortProperty = gGroups.SortProperty; var qry = groupService.Queryable(); List <int> groupTypeIds = AttributeValue("GroupTypes").SplitDelimitedValues().Select(a => int.Parse(a)).ToList(); if (groupTypeIds.Count > 0) { qry = qry.Where(a => groupTypeIds.Contains(a.GroupTypeId)); } if (AttributeValue("LimittoSecurityRoleGroups").FromTrueFalse()) { qry = qry.Where(a => a.IsSecurityRole); } if (ContextEntities.ContainsKey("Rock.Model.Group")) { Group parentGroup = ContextEntities["Rock.Model.Group"] as Group; if (parentGroup != null) { qry = qry.Where(a => a.IsAncestorOfGroup(parentGroup.Id)); } } if (sortProperty != null) { gGroups.DataSource = qry.Sort(sortProperty).ToList(); } else { gGroups.DataSource = qry.OrderBy(p => p.Name).ToList(); } gGroups.DataBind(); }