/// <summary>
        /// Get the actual media folder model for deleting or editing
        /// </summary>
        /// <returns></returns>
        private MediaFolder GetMediaFolder(RockContext rockContext = null)
        {
            rockContext = rockContext ?? new RockContext();
            var mediaFolderService = new MediaFolderService(rockContext);

            var mediaFolderId = PageParameter(PageParameterKey.MediaFolderId).AsIntegerOrNull();

            if (!mediaFolderId.HasValue)
            {
                return(null);
            }

            return(mediaFolderService.Queryable("MediaAccount").FirstOrDefault(a => a.Id == mediaFolderId.Value));
        }
        /// <summary>
        /// Binds the grid.
        /// </summary>
        private void BindGrid()
        {
            var rockContext        = new RockContext();
            var mediaFolderService = new MediaFolderService(rockContext);

            // Use AsNoTracking() since these records won't be modified, and therefore don't need to be tracked by the EF change tracker
            var qry = mediaFolderService.Queryable().AsNoTracking().Where(a => a.MediaAccountId == _mediaAccount.Id);

            // name filter
            string nameFilter = gfFilter.GetUserPreference(UserPreferenceKey.Name);

            if (!string.IsNullOrEmpty(nameFilter))
            {
                qry = qry.Where(a => a.Name.Contains(nameFilter));
            }

            var selectQry = qry
                            .Select(a => new
            {
                a.Id,
                a.Name,
                ContentChannel = a.ContentChannel,
                Videos         = a.MediaElements.Count
            });

            var sortProperty = gFolderList.SortProperty;

            if (gFolderList.AllowSorting && sortProperty != null)
            {
                selectQry = selectQry.Sort(sortProperty);
            }
            else
            {
                selectQry = selectQry.OrderBy(a => a.Name);
            }

            gFolderList.EntityTypeId = EntityTypeCache.GetId <MediaFolder>();
            gFolderList.DataSource   = selectQry.ToList();
            gFolderList.DataBind();
        }