/// <summary> /// Shows the detail. /// </summary> /// <param name="itemKey">The item key.</param> /// <param name="itemKeyValue">The location id.</param> public void ShowDetail( string itemKey, int itemKeyValue, int? parentLocationId ) { pnlDetails.Visible = false; if ( !itemKey.Equals( "LocationId" ) ) { return; } bool editAllowed = true; Location location = null; if ( !itemKeyValue.Equals( 0 ) ) { location = new LocationService( new RockContext() ).Get( itemKeyValue ); if ( location != null ) { editAllowed = location.IsAuthorized( Authorization.EDIT, CurrentPerson ); } } else { location = new Location { Id = 0, IsActive = true, ParentLocationId = parentLocationId }; } if ( location == null ) { return; } pnlDetails.Visible = true; hfLocationId.Value = location.Id.ToString(); // render UI based on Authorized and IsSystem bool readOnly = false; nbEditModeMessage.Text = string.Empty; if ( !editAllowed || !IsUserAuthorized( Authorization.EDIT ) ) { readOnly = true; nbEditModeMessage.Text = EditModeMessage.ReadOnlyEditActionNotAllowed( Location.FriendlyTypeName ); } if ( readOnly ) { btnEdit.Visible = false; btnDelete.Visible = false; ShowReadonlyDetails( location ); } else { btnEdit.Visible = true; btnDelete.Visible = true; if ( location.Id > 0 ) { ShowReadonlyDetails( location ); } else { ShowEditDetails( location ); } } }