/// <summary> /// Binds the template picker. /// </summary> /// <returns><c>true</c> if any templates were displayed.</returns> private bool BindTemplatePicker() { var rockContext = new RockContext(); var templateQuery = new CommunicationTemplateService(rockContext) .Queryable() .AsNoTracking() .Where(a => a.IsActive); int?categoryId = cpCommunicationTemplate.SelectedValue.AsIntegerOrNull(); if (categoryId.HasValue && categoryId > 0) { templateQuery = templateQuery.Where(a => a.CategoryId == categoryId); } templateQuery = templateQuery.OrderBy(a => a.Name); // get list of push templates that the current user is authorized to View IEnumerable <CommunicationTemplate> templateList = templateQuery.AsNoTracking() .ToList() .Where(a => a.IsAuthorized(Rock.Security.Authorization.VIEW, this.CurrentPerson)) .Where(a => a.PushMessage.IsNotNullOrWhiteSpace()) .ToList(); rptSelectTemplate.DataSource = templateList; rptSelectTemplate.DataBind(); return(templateList.Any()); }