Ejemplo n.º 1
0
        /// <summary>
        /// Creates the child controls.
        /// </summary>
        /// <param name="parentControl"></param>
        /// <returns></returns>
        public override System.Web.UI.Control[] CreateChildControls(System.Web.UI.Control parentControl)
        {
            var cblNoteTypes = new RockListBox();

            cblNoteTypes.ID    = parentControl.GetChildControlInstanceName(_CtlNoteTypes);
            cblNoteTypes.Label = "Note Types";
            cblNoteTypes.Help  = "The type of note to filter by. Leave blank to include all note types.";
            parentControl.Controls.Add(cblNoteTypes);

            var noteTypeService    = new NoteTypeService(new RockContext());
            var entityTypeIdPerson = EntityTypeCache.GetId <Rock.Model.Person>();
            var noteTypes          = noteTypeService.Queryable()
                                     .Where(a => a.EntityTypeId == entityTypeIdPerson)
                                     .OrderBy(a => a.Order)
                                     .ThenBy(a => a.Name)
                                     .Select(a => new
            {
                a.Id,
                a.Name
            }).ToList();

            cblNoteTypes.Items.Clear();
            cblNoteTypes.Items.AddRange(noteTypes.Select(a => new ListItem(a.Name, a.Id.ToString())).ToArray());

            var slidingDateRangePicker = new SlidingDateRangePicker();

            slidingDateRangePicker.ID       = parentControl.GetChildControlInstanceName(_CtlSlidingDateRangePicker);
            slidingDateRangePicker.Label    = "Date Range";
            slidingDateRangePicker.Help     = "The date range that the note was created during.";
            slidingDateRangePicker.Required = false;
            parentControl.Controls.Add(slidingDateRangePicker);

            return(new System.Web.UI.Control[] { cblNoteTypes, slidingDateRangePicker });
        }