protected void mdLocationPicker_SaveClick(object sender, EventArgs e) { // Add the location (ignore if they didn't pick one, or they picked one that already is selected) var location = new LocationService(new RockContext()).Get(locationPicker.SelectedValue.AsInteger()); if (location != null) { if (!checkinGroup.Locations.Any(a => a.LocationId == location.Id)) { var gridItem = new CheckinGroup.LocationGridItem(); gridItem.LocationId = location.Id; gridItem.Name = location.Name; gridItem.FullNamePath = location.Name; gridItem.ParentLocationId = location.ParentLocationId; var max = checkinGroup.Locations.Max(l => l.Order); gridItem.Order = (max == null) ? 0 : max + 1; var parentLocation = location.ParentLocation; while (parentLocation != null) { gridItem.FullNamePath = parentLocation.Name + " > " + gridItem.FullNamePath; parentLocation = parentLocation.ParentLocation; } checkinGroup.Locations.Add(gridItem); hfIsDirty.Value = "true"; } } mdLocationPicker.Hide(); }
private void SelectGroup(Guid?groupGuid) { hfIsDirty.Value = "false"; checkinArea.Visible = false; checkinGroup.Visible = false; btnSave.Visible = false; if (groupGuid.HasValue) { using (var rockContext = new RockContext()) { var groupService = new GroupService(rockContext); var group = groupService.Get(groupGuid.Value); if (group != null) { _currentGroupGuid = group.Guid; checkinGroup.SetGroup(group, rockContext); var locationService = new LocationService(rockContext); var locationQry = locationService.Queryable().Select(a => new { a.Id, a.ParentLocationId, a.Name }); checkinGroup.Locations = new List <CheckinGroup.LocationGridItem>(); foreach (var location in group.GroupLocations.Select(a => a.Location).OrderBy(o => o.Name)) { var gridItem = new CheckinGroup.LocationGridItem(); gridItem.LocationId = location.Id; gridItem.Name = location.Name; gridItem.FullNamePath = location.Name; gridItem.ParentLocationId = location.ParentLocationId; var parentLocationId = location.ParentLocationId; while (parentLocationId != null) { var parentLocation = locationQry.FirstOrDefault(a => a.Id == parentLocationId); gridItem.FullNamePath = parentLocation.Name + " > " + gridItem.FullNamePath; parentLocationId = parentLocation.ParentLocationId; } checkinGroup.Locations.Add(gridItem); } checkinGroup.Visible = true; btnSave.Visible = true; } else { _currentGroupGuid = null; } } } else { _currentGroupGuid = null; checkinGroup.CreateGroupAttributeControls(null, null); } BuildRows(); }
private void SelectGroup(Guid?groupGuid) { hfIsDirty.Value = "false"; checkinArea.Visible = false; checkinGroup.Visible = false; btnSave.Visible = false; btnDelete.Visible = false; if (groupGuid.HasValue) { using (var rockContext = new RockContext()) { var groupService = new GroupService(rockContext); var group = groupService.Get(groupGuid.Value); if (group != null) { _currentGroupGuid = group.Guid; checkinGroup.SetGroup(group, rockContext); var locationService = new LocationService(rockContext); var locationQry = locationService.Queryable().Select(a => new { a.Id, a.ParentLocationId, a.Name }); checkinGroup.Locations = new List <CheckinGroup.LocationGridItem>(); foreach (var groupLocation in group.GroupLocations.OrderBy(gl => gl.Order).ThenBy(gl => gl.Location.Name)) { var location = groupLocation.Location; var gridItem = new CheckinGroup.LocationGridItem(); gridItem.LocationId = location.Id; gridItem.Name = location.Name; gridItem.FullNamePath = location.Name; gridItem.ParentLocationId = location.ParentLocationId; gridItem.Order = groupLocation.Order; var parentLocationId = location.ParentLocationId; while (parentLocationId != null) { var parentLocation = locationQry.FirstOrDefault(a => a.Id == parentLocationId); gridItem.FullNamePath = parentLocation.Name + " > " + gridItem.FullNamePath; parentLocationId = parentLocation.ParentLocationId; } checkinGroup.Locations.Add(gridItem); } checkinGroup.Visible = true; btnSave.Visible = true; btnDelete.Visible = true; btnDelete.Attributes["onclick"] = string.Format("javascript: return Rock.dialogs.confirmDelete(event, '{0}', '{1}');", "check-in group", "<br>Any attendance records connected with this group will be lost. This action cannot be undone."); } else { _currentGroupGuid = null; } } } else { _currentGroupGuid = null; checkinGroup.CreateGroupAttributeControls(null, null); } BuildRows(); }