/// <summary>
        /// Binds the group members grid.
        /// </summary>
        protected void BindGrid()
        {
            using (var rockContext = new RockContext())
            {
                var pageShortLinkService = new PageShortLinkService(rockContext);

                var qry = pageShortLinkService.Queryable().ToList()
                          .Select(s => new ShortLinkRow(s))
                          .ToList()
                          .AsQueryable();


                SortProperty sortProperty = gShortLinks.SortProperty;
                if (sortProperty != null)
                {
                    gShortLinks.DataSource = qry.Sort(sortProperty).ToList();
                }
                else
                {
                    gShortLinks.DataSource = qry.OrderBy(l => l.Token).ToList();
                }

                gShortLinks.DataBind();
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Binds the group members grid.
        /// </summary>
        protected void BindGrid()
        {
            using (var rockContext = new RockContext())
            {
                var pageShortLinkService = new PageShortLinkService(rockContext);

                var shortLinkQry = pageShortLinkService.Queryable();

                string token = gfShortLink.GetUserPreference(FilterAttributeKeys.Token);
                if (!string.IsNullOrEmpty(token))
                {
                    shortLinkQry = shortLinkQry.Where(s => s.Token.Contains(token));
                }

                int?siteId = gfShortLink.GetUserPreference(FilterAttributeKeys.Site).AsIntegerOrNull();
                if (siteId.HasValue)
                {
                    shortLinkQry = shortLinkQry.Where(s => s.SiteId == siteId.Value);
                }


                var qry = shortLinkQry.ToList()
                          .Select(s => new ShortLinkRow(s))
                          .ToList()
                          .AsQueryable();

                SortProperty sortProperty = gShortLinks.SortProperty;
                if (sortProperty != null)
                {
                    gShortLinks.DataSource = qry.Sort(sortProperty).ToList();
                }
                else
                {
                    gShortLinks.DataSource = qry.OrderBy(l => l.Token).ToList();
                }

                gShortLinks.DataBind();
            }
        }