Example #1
0
        protected void gKioskType_Delete(object sender, RowEventArgs e)
        {
            var checkinContext = new RockContext();
            KioskTypeService KioskTypeService = new KioskTypeService(checkinContext);
            KioskType        KioskType        = KioskTypeService.Get(e.RowKeyId);

            if (KioskType != null)
            {
                int kosktypeId = KioskType.Id;

                string errorMessage;
                if (!KioskTypeService.CanDelete(KioskType, out errorMessage))
                {
                    mdGridWarning.Show(errorMessage, ModalAlertType.Information);
                    return;
                }

                KioskTypeService.Delete(KioskType);
                checkinContext.SaveChanges();

                KioskTypeCache.Clear();
                KioskDeviceHelpers.Clear();
            }

            BindGrid();
        }
Example #2
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);
        }
 protected void btnFlushKioskTypes_Click(object sender, EventArgs e)
 {
     KioskTypeCache.Clear();
     KioskTypeCache.All();
 }