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(); Rock.CheckIn.KioskDevice.FlushAll(); } BindGrid(); }
protected void btnSelectKiosk_Click(object sender, EventArgs e) { var rockContext = new RockContext(); var kioskTypeService = new KioskTypeService(rockContext); var kioskType = kioskTypeService.Get(ddlManualKioskType.SelectedValue.AsInteger()); if (kioskType == null) { return; } var kioskService = new KioskService(rockContext); var kiosk = kioskService.GetByClientName(CurrentUser.UserName); if (kiosk == null) { kiosk = new Kiosk(); kiosk.Name = CurrentUser.UserName; kiosk.Description = "Automatically created personal Kiosk"; kioskService.Add(kiosk); } kiosk.KioskTypeId = kioskType.Id; kiosk.CategoryId = CategoryCache.GetId(Constants.KIOSK_CATEGORY_STAFFUSER.AsGuid()); rockContext.SaveChanges(); SetBlockUserPreference("KioskTypeId", kioskType.Id.ToString()); ActivateKiosk(kiosk, false); }
protected void btnSelectKiosk_Click(object sender, EventArgs e) { var rockContext = new RockContext(); var kioskTypeService = new KioskTypeService(rockContext); var kioskType = kioskTypeService.Get(ddlKioskType.SelectedValue.AsInteger()); if (kioskType == null) { return; } var kioskService = new KioskService(rockContext); var kiosk = kioskService.GetByClientName(CurrentUser.UserName); if (kiosk == null) { kiosk = new Kiosk(); kiosk.Name = CurrentUser.UserName; kiosk.Description = "Automatically created personal Kiosk"; kioskService.Add(kiosk); } kiosk.KioskTypeId = kioskType.Id; rockContext.SaveChanges(); GetKioskType(kiosk, rockContext); }
protected void btnSave_Click(object sender, EventArgs e) { KioskType KioskType = null; var rockContext = new RockContext(); var kioskTypeService = new KioskTypeService(rockContext); var attributeService = new AttributeService(rockContext); var locationService = new LocationService(rockContext); var scheduleService = new ScheduleService(rockContext); var groupTypeService = new GroupTypeService(rockContext); int KioskTypeId = int.Parse(hfKioskTypeId.Value); if (KioskTypeId != 0) { KioskType = kioskTypeService.Get(KioskTypeId); } if (KioskType == null) { KioskType = new KioskType(); kioskTypeService.Add(KioskType); } if (KioskType != null) { KioskType.Name = tbName.Text; KioskType.Description = tbDescription.Text; KioskType.Message = tbMessage.Text; if (!KioskType.IsValid || !Page.IsValid) { // Controls will render the error messages return; } // Remove any deleted locations foreach (var location in KioskType.Locations .Where(l => !Locations.Keys.Contains(l.Id)) .ToList()) { KioskType.Locations.Remove(location); } // Remove any deleted schedules foreach (var schedule in KioskType.Schedules .Where(s => !Schedules.Keys.Contains(s.Id)) .ToList()) { KioskType.Schedules.Remove(schedule); } // Add any new locations var existingLocationIDs = KioskType.Locations.Select(l => l.Id).ToList(); foreach (var location in locationService.Queryable() .Where(l => Locations.Keys.Contains(l.Id) && !existingLocationIDs.Contains(l.Id))) { KioskType.Locations.Add(location); } // Add any new schedules var existingScheduleIDs = KioskType.Schedules.Select(s => s.Id).ToList(); foreach (var schedule in scheduleService.Queryable() .Where(s => Schedules.Keys.Contains(s.Id) && !existingScheduleIDs.Contains(s.Id))) { KioskType.Schedules.Add(schedule); } //Save checkin template KioskType.CheckinTemplateId = ddlTemplates.SelectedValue.AsInteger(); var GroupTypes = KioskType.GroupTypes; GroupTypes.Clear(); foreach (ListItem item in cblPrimaryGroupTypes.Items) { if (item.Selected) { GroupTypes.Add(groupTypeService.Get(item.Value.AsInteger())); } } rockContext.SaveChanges(); Rock.CheckIn.KioskDevice.FlushAll(); NavigateToParentPage(); } }