示例#1
0
        private void LoadStatusList()
        {
            cblStatus.Items.Clear();
            var statusLookups = definedTypeService.Get(new Guid(CapitalRequest.STATUS_LOOKUP_TYPE_GUID));

            cblStatus.DataSource     = statusLookups.DefinedValues.Where(l => l.IsValid).OrderBy(l => l.Order);
            cblStatus.DataValueField = "Id";
            cblStatus.DataTextField  = "Value";
            cblStatus.DataBind();
        }
示例#2
0
        /// <summary>
        /// Handles the Click event of the btnEdit control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        protected void btnEdit_Click(object sender, EventArgs e)
        {
            DefinedTypeService definedTypeService = new DefinedTypeService(new RockContext());
            DefinedType        definedType        = definedTypeService.Get(hfDefinedTypeId.ValueAsInt());

            ShowEditDetails(definedType);
        }
示例#3
0
        /// <summary>
        /// Handles the Click event of the btnDelete control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            RockContext        rockContext        = new RockContext();
            DefinedTypeService definedTypeService = new DefinedTypeService(rockContext);
            DefinedType        definedType        = definedTypeService.Get(int.Parse(hfDefinedTypeId.Value));

            if (definedType != null)
            {
                if (!definedType.IsAuthorized(Authorization.EDIT, this.CurrentPerson))
                {
                    mdDeleteWarning.Show("Sorry, You are not authorized to delete this Defined Type.", ModalAlertType.Information);
                    return;
                }

                string errorMessage;
                if (!definedTypeService.CanDelete(definedType, out errorMessage))
                {
                    mdDeleteWarning.Show(errorMessage, ModalAlertType.Information);
                    return;
                }

                definedTypeService.Delete(definedType);

                rockContext.SaveChanges();
            }

            NavigateToParentPage();
        }
示例#4
0
        private void BindLocationList()
        {
            AttributeService attributeService = new AttributeService(new RockContext());

            Rock.Model.Attribute locationAttribute = attributeService.Get(MinistryLocationAttributeIDSetting);

            if (locationAttribute != null)
            {
                ddlLocation.Items.Clear();
                ddlLocation.DataSource     = definedTypeService.Get(locationAttribute.AttributeQualifiers.Where(aq => aq.Key == "definedtype").FirstOrDefault().Value.AsInteger()).DefinedValues.OrderBy(l => l.Order);
                ddlLocation.DataTextField  = "Value";
                ddlLocation.DataValueField = "Id";
                ddlLocation.DataBind();

                ddlLocation.Items.Insert(0, new ListItem("<All>", "0"));
                ddlLocation.SelectedValue = "0";
            }
        }
        /// <summary>
        /// Handles the Click event of the btnSaveType control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        protected void btnSaveType_Click(object sender, EventArgs e)
        {
            DefinedType        definedType = null;
            DefinedTypeService typeService = new DefinedTypeService();

            int definedTypeId = hfDefinedTypeId.ValueAsInt();

            if (definedTypeId == 0)
            {
                definedType          = new DefinedType();
                definedType.IsSystem = false;
                definedType.Order    = 0;
                typeService.Add(definedType, CurrentPersonId);
            }
            else
            {
                DefinedTypeCache.Flush(definedTypeId);
                definedType = typeService.Get(definedTypeId);
            }

            definedType.Name        = tbTypeName.Text;
            definedType.Category    = tbTypeCategory.Text;
            definedType.Description = tbTypeDescription.Text;
            definedType.FieldTypeId = int.Parse(ddlTypeFieldType.SelectedValue);

            if (!definedType.IsValid)
            {
                // Controls will render the error messages
                return;
            }

            RockTransactionScope.WrapTransaction(() =>
            {
                typeService.Save(definedType, CurrentPersonId);

                // get it back to make sure we have a good Id
                definedType = typeService.Get(definedType.Guid);
            });

            var qryParams = new Dictionary <string, string>();

            qryParams["definedTypeId"] = definedType.Id.ToString();
            NavigateToPage(this.CurrentPage.Guid, qryParams);
        }
示例#6
0
        /// <summary>
        /// Handles the Click event of the btnSaveType control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        protected void btnSaveType_Click(object sender, EventArgs e)
        {
            DefinedType        definedType = null;
            DefinedTypeService typeService = new DefinedTypeService();

            int definedTypeId = hfDefinedTypeId.ValueAsInt();

            if (definedTypeId == 0)
            {
                definedType          = new DefinedType();
                definedType.IsSystem = false;
                definedType.Order    = 0;
                typeService.Add(definedType, CurrentPersonId);
            }
            else
            {
                Rock.Web.Cache.DefinedTypeCache.Flush(definedTypeId);
                definedType = typeService.Get(definedTypeId);
            }

            definedType.Name        = tbTypeName.Text;
            definedType.Category    = tbTypeCategory.Text;
            definedType.Description = tbTypeDescription.Text;
            definedType.FieldTypeId = int.Parse(ddlTypeFieldType.SelectedValue);

            if (!definedType.IsValid)
            {
                // Controls will render the error messages
                return;
            }

            RockTransactionScope.WrapTransaction(() =>
            {
                typeService.Save(definedType, CurrentPersonId);

                // get it back to make sure we have a good Id
                definedType = typeService.Get(definedType.Guid);
            });

            ShowReadonlyDetails(definedType);
        }
        /// <summary>
        /// Executes the specified context.
        /// </summary>
        /// <param name="context">The context.</param>
        public void Execute(IJobExecutionContext context)
        {
            JobDataMap dataMap = context.JobDetail.JobDataMap;

            var rockContext     = new RockContext();
            var definedTypeGuid = dataMap.GetString("DisabledGroupLocationSchedules").AsGuidOrNull();

            if (definedTypeGuid == null)
            {
                return;
            }
            var definedTypeService   = new DefinedTypeService(rockContext);
            var definedValueService  = new DefinedValueService(rockContext);
            var dtDeactivated        = definedTypeService.Get(definedTypeGuid ?? new Guid());
            var dvDeactivated        = dtDeactivated.DefinedValues.ToList();
            var scheduleService      = new ScheduleService(rockContext);
            var groupLocationService = new GroupLocationService(rockContext);
            var deactivatedGroupLocationSchedules = dvDeactivated.Select(dv => dv.Value.Split('|'))
                                                    .Select(s => new
            {
                GroupLocation = groupLocationService.Get(s[0].AsInteger()),
                Schedule      = scheduleService.Get(s[1].AsInteger()),
            }).ToList();

            //add schedules back
            foreach (var groupLocationSchedule in deactivatedGroupLocationSchedules)
            {
                if (!groupLocationSchedule.GroupLocation.Schedules.Contains(groupLocationSchedule.Schedule))
                {
                    groupLocationSchedule.GroupLocation.Schedules.Add(groupLocationSchedule.Schedule);
                }
            }
            //Remove defined values
            foreach (var value in dvDeactivated)
            {
                definedValueService.Delete(value);
                Rock.Web.Cache.DefinedValueCache.Remove(value.Id);
            }

            //clear defined type cache
            Rock.Web.Cache.DefinedTypeCache.Remove(dtDeactivated.Id);

            rockContext.SaveChanges();

            //flush kiosk cache
            Rock.CheckIn.KioskDevice.Clear();

            context.Result = string.Format("Finished at {0}. Reset {1} GroupScheduleLocations.", Rock.RockDateTime.Now, deactivatedGroupLocationSchedules.Count);
        }
示例#8
0
 /// <summary>
 /// Handles the Click event of the btnCancelType control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
 protected void btnCancelType_Click(object sender, EventArgs e)
 {
     if (hfDefinedTypeId.IsZero())
     {
         // Cancelling on Add.  Return to Grid
         NavigateToParentPage();
     }
     else
     {
         // Cancelling on Edit.  Return to Details
         DefinedTypeService definedTypeService = new DefinedTypeService(new RockContext());
         DefinedType        definedType        = definedTypeService.Get(hfDefinedTypeId.ValueAsInt());
         ShowReadonlyDetails(definedType);
     }
 }
示例#9
0
        /// <summary>
        /// Executes the specified context.
        /// </summary>
        /// <param name="context">The context.</param>
        public void Execute(IJobExecutionContext context)
        {
            JobDataMap dataMap = context.JobDetail.JobDataMap;

            var rockContext = new RockContext();

            var definedTypeService   = new DefinedTypeService(rockContext);
            var definedValueService  = new DefinedValueService(rockContext);
            var dtDeactivated        = definedTypeService.Get(Constants.DEFINED_TYPE_DISABLED_GROUPLOCATIONSCHEDULES.AsGuid());
            var dvDeactivated        = dtDeactivated.DefinedValues.ToList();
            var scheduleService      = new ScheduleService(rockContext);
            var groupLocationService = new GroupLocationService(rockContext);
            var deactivatedGroupLocationSchedules = dvDeactivated.Select(dv => dv.Value.Split('|'))
                                                    .Select(s => new
            {
                GroupLocation = groupLocationService.Get(s[0].AsInteger()),
                Schedule      = scheduleService.Get(s[1].AsInteger()),
            }).ToList();

            //add schedules back
            foreach (var groupLocationSchedule in deactivatedGroupLocationSchedules)
            {
                if (!groupLocationSchedule.GroupLocation.Schedules.Contains(groupLocationSchedule.Schedule))
                {
                    groupLocationSchedule.GroupLocation.Schedules.Add(groupLocationSchedule.Schedule);
                }
            }
            //Remove defined values
            foreach (var value in dvDeactivated)
            {
                definedValueService.Delete(value);
                Rock.Web.Cache.DefinedValueCache.Remove(value.Id);
            }

            //clear defined type cache
            Rock.Web.Cache.DefinedTypeCache.Remove(dtDeactivated.Id);

            rockContext.SaveChanges();

            //clear caches
            KioskTypeCache.Clear();
            Rock.CheckIn.KioskDevice.Clear();
            OccurrenceCache.Clear();
            AttendanceCache.Clear();

            context.Result = string.Format("Finished at {0}. Reset {1} GroupScheduleLocations.", Rock.RockDateTime.Now, deactivatedGroupLocationSchedules.Count);
        }
        /// <summary>
        /// Handles the Delete event of the gDefinedType control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="RowEventArgs" /> instance containing the event data.</param>
        protected void gDefinedType_Delete(object sender, RowEventArgs e)
        {
            var definedValueService = new DefinedValueService();
            var definedTypeService  = new DefinedTypeService();

            DefinedType type = definedTypeService.Get(e.RowKeyId);

            if (type != null)
            {
                string errorMessage;
                if (!definedTypeService.CanDelete(type, out errorMessage))
                {
                    mdGridWarning.Show(errorMessage, ModalAlertType.Information);
                    return;
                }

                // if this DefinedType has DefinedValues, see if they can be deleted
                var definedValues = definedValueService.GetByDefinedTypeId(type.Id).ToList();

                foreach (var value in definedValues)
                {
                    if (!definedValueService.CanDelete(value, out errorMessage))
                    {
                        mdGridWarning.Show(errorMessage, ModalAlertType.Information);
                        return;
                    }
                }

                RockTransactionScope.WrapTransaction(() =>
                {
                    foreach (var value in definedValues)
                    {
                        definedValueService.Delete(value, CurrentPersonId);
                        definedValueService.Save(value, CurrentPersonId);
                    }

                    definedTypeService.Delete(type, CurrentPersonId);
                    definedTypeService.Save(type, CurrentPersonId);
                });
            }

            gDefinedType_Bind();
        }
        /// <summary>
        /// Handles the Delete event of the gDefinedType control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="RowEventArgs" /> instance containing the event data.</param>
        protected void gDefinedType_Delete(object sender, RowEventArgs e)
        {
            var rockContext         = new RockContext();
            var definedValueService = new DefinedValueService(rockContext);
            var definedTypeService  = new DefinedTypeService(rockContext);

            DefinedType type = definedTypeService.Get(e.RowKeyId);

            if (type != null)
            {
                string errorMessage;
                if (!definedTypeService.CanDelete(type, out errorMessage))
                {
                    mdGridWarning.Show(errorMessage, ModalAlertType.Information);
                    return;
                }

                // if this DefinedType has DefinedValues, see if they can be deleted
                var definedValues = definedValueService.GetByDefinedTypeId(type.Id).ToList();

                foreach (var value in definedValues)
                {
                    if (!definedValueService.CanDelete(value, out errorMessage))
                    {
                        mdGridWarning.Show(errorMessage, ModalAlertType.Information);
                        return;
                    }
                }

                foreach (var value in definedValues)
                {
                    definedValueService.Delete(value);
                }

                definedTypeService.Delete(type);

                rockContext.SaveChanges();
            }

            gDefinedType_Bind();
        }
示例#12
0
        /// <summary>
        /// Handles the Click event of the btnSaveType control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        protected void btnSaveType_Click(object sender, EventArgs e)
        {
            var rockContext = new RockContext();

            DefinedType        definedType = null;
            DefinedTypeService typeService = new DefinedTypeService(rockContext);

            int definedTypeId = hfDefinedTypeId.ValueAsInt();

            if (definedTypeId == 0)
            {
                definedType          = new DefinedType();
                definedType.IsSystem = false;
                definedType.Order    = 0;
                typeService.Add(definedType);
            }
            else
            {
                DefinedTypeCache.Flush(definedTypeId);
                definedType = typeService.Get(definedTypeId);
            }

            definedType.FieldTypeId = FieldTypeCache.Read(Rock.SystemGuid.FieldType.TEXT).Id;
            definedType.Name        = tbTypeName.Text;
            definedType.CategoryId  = cpCategory.SelectedValueAsInt();
            definedType.Description = tbTypeDescription.Text;
            definedType.HelpText    = tbHelpText.Text;

            if (!definedType.IsValid)
            {
                // Controls will render the error messages
                return;
            }

            rockContext.SaveChanges();

            var qryParams = new Dictionary <string, string>();

            qryParams["definedTypeId"] = definedType.Id.ToString();
            NavigateToPage(RockPage.Guid, qryParams);
        }
示例#13
0
        protected void btnSaveType_Click(object sender, EventArgs e)
        {
            using (new Rock.Data.UnitOfWorkScope())
            {
                DefinedTypeService typeService = new DefinedTypeService();

                DefinedType definedType;

                int typeId = ((hfIdType.Value) != null && hfIdType.Value != String.Empty) ? Int32.Parse(hfIdType.Value) : 0;

                if (typeId == 0)
                {
                    definedType          = new DefinedType();
                    definedType.IsSystem = false;
                    definedType.Order    = 0;
                    typeService.Add(definedType, CurrentPersonId);
                }
                else
                {
                    Rock.Web.Cache.DefinedTypeCache.Flush(typeId);
                    definedType = typeService.Get(typeId);
                }

                definedType.Name        = tbTypeName.Text;
                definedType.Category    = tbTypeCategory.Text;
                definedType.Description = tbTypeDescription.Text;
                definedType.FieldTypeId = Int32.Parse(ddlTypeFieldType.SelectedValue);

                typeService.Save(definedType, CurrentPersonId);
            }

            rGridType_Bind();

            pnlTypeDetails.Visible = false;
            pnlTypes.Visible       = true;
        }
示例#14
0
        /// <summary>
        /// Loads the drop downs.
        /// </summary>
        private bool SetFilters()
        {
            //Check for Campus Parameter
            var campusId  = PageParameter(GetAttributeValue("CampusParameterName")).AsIntegerOrNull();
            var campusStr = PageParameter("Campus");

            // Setup Campus Filter
            cblCampus.DataSource = CampusCache.All();
            cblCampus.DataBind();

            if (campusId.HasValue)
            {
                //check if there's a campus with this id.
                var campus = CampusCache.Get(campusId.Value);
                if (campus != null)
                {
                    cblCampus.SetValue(campusId.Value);
                }
            }
            else if (!string.IsNullOrEmpty(campusStr))
            {
                //check if there's a campus with this name.
                campusStr = campusStr.Replace(" ", "").Replace("-", "");
                var campusCache = CampusCache.All().Where(c => c.Name.ToLower().Replace(" ", "").Replace("-", "") == campusStr.ToLower()).FirstOrDefault();
                if (campusCache != null)
                {
                    cblCampus.SetValue(campusCache.Id);
                }
            }


            // Setup Category Filter
            var selectedCategoryGuids = GetAttributeValue("FilterCategories").SplitDelimitedValues(true).AsGuidList();

            rcwCategory.Visible = selectedCategoryGuids.Any() && GetAttributeValue("CategoryFilterDisplayMode").AsInteger() > 1;
            var definedType = DefinedTypeCache.Get(Rock.SystemGuid.DefinedType.MARKETING_CAMPAIGN_AUDIENCE_TYPE.AsGuid());

            if (definedType != null)
            {
                var categoryItems = definedType.DefinedValues.ToList();
                if (selectedCategoryGuids.Count() > 0)
                {
                    categoryItems = definedType.DefinedValues.Where(v => selectedCategoryGuids.Contains(v.Guid)).ToList();
                }
                cblCategory.DataSource = categoryItems;
                cblCategory.DataBind();
            }

            var categoryId   = PageParameter(GetAttributeValue("CategoryParameterName")).AsIntegerOrNull();
            var ministrySlug = PageParameter("ministry").ToLower();

            if (categoryId.HasValue)
            {
                if (definedType.DefinedValues.Where(v => (selectedCategoryGuids.Contains(v.Guid) || selectedCategoryGuids.Count() == 0) && v.Id == categoryId.Value).FirstOrDefault() != null)
                {
                    cblCategory.SetValue(categoryId.Value);
                }
            }
            else if (!string.IsNullOrEmpty(ministrySlug))
            {
                var definedValues = definedType.DefinedValues.Where(v => (selectedCategoryGuids.Contains(v.Guid) || selectedCategoryGuids.Count() == 0)).ToList();
                DefinedTypeService definedTypeService = new DefinedTypeService(new RockContext());
                var definedTypeModel = definedTypeService.Get(definedType.Guid);
                foreach (var dv in definedTypeModel.DefinedValues)
                {
                    dv.LoadAttributes();
                    if (dv.GetAttributeValue("URLSlug") == ministrySlug)
                    {
                        cblCategory.SetValue(dv.Id);
                        break;
                    }
                }
            }

            // Set filter visibility
            bool showFilter = (rcwCampus.Visible || rcwCategory.Visible);

            pnlFilters.Visible = false; // hide for now... otherwise it should be managed by the block ^^^

            return(true);
        }
示例#15
0
        /// <summary>
        /// Loads the drop downs.
        /// </summary>
        private bool SetFilterControls()
        {
            // Get and verify the calendar id
            if (_calendarId <= 0)
            {
                ShowError("Configuration Error", "The 'Event Calendar' setting has not been set correctly.");
                return(false);
            }

            // Get and verify the view mode
            ViewMode = GetAttributeValue("DefaultViewOption");
            if (!GetAttributeValue(string.Format("Show{0}View", ViewMode)).AsBoolean())
            {
                ShowError("Configuration Error", string.Format("The Default View Option setting has been set to '{0}', but the Show {0} View setting has not been enabled.", ViewMode));
                return(false);
            }

            // Show/Hide calendar control
            pnlCalendar.Visible = GetAttributeValue("ShowSmallCalendar").AsBoolean();

            // Get the first/last dates based on today's date and the viewmode setting
            var today = RockDateTime.Now;

            FilterStartDate = today;
            FilterEndDate   = today;
            if (ViewMode == "Week")
            {
                FilterStartDate = today.StartOfWeek(_firstDayOfWeek);
                FilterEndDate   = today.EndOfWeek(_firstDayOfWeek);
            }
            else if (ViewMode == "Month")
            {
                FilterStartDate = new DateTime(today.Year, today.Month, 1);
                FilterEndDate   = FilterStartDate.Value.AddMonths(1).AddDays(-1);
            }
            else if (ViewMode == "Year")
            {
                FilterEndDate = FilterStartDate.Value.AddYears(1).AddDays(-1);
            }

            // Setup small calendar Filter
            calEventCalendar.FirstDayOfWeek = _firstDayOfWeek.ConvertToInt().ToString().ConvertToEnum <FirstDayOfWeek>();
            calEventCalendar.SelectedDates.Clear();
            calEventCalendar.SelectedDates.SelectRange(FilterStartDate.Value, FilterEndDate.Value);

            // Setup Campus Filter
            rcwCampus.Visible    = GetAttributeValue("CampusFilterDisplayMode").AsInteger() > 1;
            cblCampus.DataSource = CampusCache.All();
            cblCampus.DataBind();

            //Check for Campus Parameter
            var campusId  = PageParameter(GetAttributeValue("CampusParameterName")).AsIntegerOrNull();
            var campusStr = PageParameter("Campus");

            if (campusId.HasValue)
            {
                //check if there's a campus with this id.
                var campus = CampusCache.Read(campusId.Value);
                if (campus != null)
                {
                    cblCampus.SetValue(campusId.Value);
                }
            }
            else if (!string.IsNullOrEmpty(campusStr))
            {
                //check if there's a campus with this name.
                campusStr = campusStr.Replace(" ", "").Replace("-", "");
                var campusCache = CampusCache.All().Where(c => c.Name.ToLower().Replace(" ", "").Replace("-", "") == campusStr.ToLower()).FirstOrDefault();
                if (campusCache != null)
                {
                    cblCampus.SetValue(campusCache.Id);
                }
            }
            else
            {
                if (GetAttributeValue("EnableCampusContext").AsBoolean())
                {
                    var contextCampus = RockPage.GetCurrentContext(EntityTypeCache.Read("Rock.Model.Campus")) as Campus;
                    if (contextCampus != null)
                    {
                        cblCampus.SetValue(contextCampus.Id);
                    }
                }
            }

            // Setup Category Filter
            var selectedCategoryGuids = GetAttributeValue("FilterCategories").SplitDelimitedValues(true).AsGuidList();

            rcwCategory.Visible = selectedCategoryGuids.Any() && GetAttributeValue("CategoryFilterDisplayMode").AsInteger() > 1;
            var definedType = DefinedTypeCache.Read(Rock.SystemGuid.DefinedType.MARKETING_CAMPAIGN_AUDIENCE_TYPE.AsGuid());

            if (definedType != null)
            {
                var categoryItems = definedType.DefinedValues.ToList();
                if (selectedCategoryGuids.Count() > 0)
                {
                    categoryItems = definedType.DefinedValues.Where(v => selectedCategoryGuids.Contains(v.Guid)).ToList();
                }
                cblCategory.DataSource = categoryItems;
                cblCategory.DataBind();
            }
            var categoryId   = PageParameter(GetAttributeValue("CategoryParameterName")).AsIntegerOrNull();
            var ministrySlug = PageParameter("ministry").ToLower();

            if (categoryId.HasValue)
            {
                if (definedType.DefinedValues.Where(v => (selectedCategoryGuids.Contains(v.Guid) || selectedCategoryGuids.Count() == 0) && v.Id == categoryId.Value).FirstOrDefault() != null)
                {
                    cblCategory.SetValue(categoryId.Value);
                }
            }
            else if (!string.IsNullOrEmpty(ministrySlug))
            {
                var definedValues = definedType.DefinedValues.Where(v => (selectedCategoryGuids.Contains(v.Guid) || selectedCategoryGuids.Count() == 0)).ToList();
                DefinedTypeService definedTypeService = new DefinedTypeService(new RockContext());
                var definedTypeModel = definedTypeService.Get(definedType.Guid);
                foreach (var dv in definedTypeModel.DefinedValues)
                {
                    dv.LoadAttributes();
                    if (dv.GetAttributeValue("URLSlug") == ministrySlug)
                    {
                        cblCategory.SetValue(dv.Id);
                        break;
                    }
                }
            }

            // Date Range Filter
            drpDateRange.Visible       = GetAttributeValue("ShowDateRangeFilter").AsBoolean();
            lbDateRangeRefresh.Visible = drpDateRange.Visible;
            drpDateRange.LowerValue    = FilterStartDate;
            drpDateRange.UpperValue    = FilterEndDate;

            // Get the View Modes, and only show them if more than one is visible
            var viewsVisible = new List <bool> {
                GetAttributeValue("ShowDayView").AsBoolean(),
                GetAttributeValue("ShowWeekView").AsBoolean(),
                GetAttributeValue("ShowMonthView").AsBoolean(),
                GetAttributeValue("ShowYearView").AsBoolean()
            };
            var howManyVisible = viewsVisible.Where(v => v).Count();

            btnDay.Visible   = howManyVisible > 1 && viewsVisible[0];
            btnWeek.Visible  = howManyVisible > 1 && viewsVisible[1];
            btnMonth.Visible = howManyVisible > 1 && viewsVisible[2];
            btnYear.Visible  = howManyVisible > 1 && viewsVisible[3];

            // Set filter visibility
            bool showFilter = (pnlCalendar.Visible || rcwCampus.Visible || rcwCategory.Visible || drpDateRange.Visible);

            pnlFilters.Visible = showFilter;
            pnlList.CssClass   = showFilter ? "col-md-9" : "col-md-12";

            return(true);
        }