/// <summary>
        /// Binds the grid.
        /// </summary>
        private void BindGrid()
        {
            var service      = new RestControllerService(new RockContext());
            var sortProperty = gControllers.SortProperty;

            var qry = service.Queryable().Select(c => new
            {
                c.Id,
                c.Name,
                c.ClassName,
                Actions = c.Actions.Count()
            });

            if (sortProperty != null)
            {
                qry = qry.Sort(sortProperty);
            }
            else
            {
                qry = qry.OrderBy(c => c.Name);
            }

            gControllers.EntityTypeId = EntityTypeCache.Get <RestController>().Id;
            gControllers.DataSource   = qry.ToList();
            gControllers.DataBind();
        }
예제 #2
0
        /// <summary>
        /// Binds the grid.
        /// </summary>
        private void BindGrid()
        {
            var service      = new RestControllerService(new RockContext());
            var sortProperty = gControllers.SortProperty;

            var qry = service.Queryable().Select(c => new RestControllerModel
            {
                Id        = c.Id,
                Name      = c.Name,
                ClassName = c.ClassName,
                Actions   = c.Actions.Count(),
                ActionsWithPublicCachingHeaders = c.Actions.Count(a => a.CacheControlHeaderSettings != null &&
                                                                  a.CacheControlHeaderSettings != "" &&
                                                                  a.CacheControlHeaderSettings.Contains("\"RockCacheablityType\":0"))
            });

            if (sortProperty != null)
            {
                qry = qry.Sort(sortProperty);
            }
            else
            {
                qry = qry.OrderBy(c => c.Name);
            }

            gControllers.EntityTypeId = EntityTypeCache.Get <RestController>().Id;
            gControllers.DataSource   = qry.ToList();
            gControllers.DataBind();
        }
예제 #3
0
        private static int LoadByName2(string className, RockContext rockContext)
        {
            var RestControllerService = new RestControllerService(rockContext);

            return(RestControllerService
                   .Queryable().AsNoTracking()
                   .Where(a => a.ClassName == className)
                   .Select(c => c.Id)
                   .FirstOrDefault());
        }
예제 #4
0
        private static int LoadByGuid2(Guid guid, RockContext rockContext)
        {
            var RestControllerService = new RestControllerService(rockContext);

            return(RestControllerService
                   .Queryable().AsNoTracking()
                   .Where(c => c.Guid.Equals(guid))
                   .Select(c => c.Id)
                   .FirstOrDefault());
        }
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Load" /> event.
        /// </summary>
        /// <param name="e">The <see cref="T:System.EventArgs" /> object that contains the event data.</param>
        protected override void OnLoad(EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                var service = new RestControllerService(new RockContext());
                if (!service.Queryable().Any())
                {
                    RefreshControllerList();
                }

                BindGrid();
            }

            base.OnLoad(e);
        }
예제 #6
0
        /// <summary>
        /// Queries the database by id with context.
        /// </summary>
        /// <param name="className">Name of the class.</param>
        /// <param name="rockContext">The rock context.</param>
        /// <returns></returns>
        private static RestControllerCache QueryDbByClassNameWithContext(string className, RockContext rockContext)
        {
            var service = new RestControllerService(rockContext);
            var entity  = service.Queryable().AsNoTracking()
                          .FirstOrDefault(a => a.ClassName == className);

            if (entity == null)
            {
                return(null);
            }

            var value = new RestControllerCache();

            value.SetFromEntity(entity);
            return(value);
        }