void lvAttributeValues_ItemUpdating(object sender, ListViewUpdateEventArgs e) { PlaceHolder phEditValue = lvAttributeValues.EditItem.FindControl("phEditValue") as PlaceHolder; if (phEditValue != null && phEditValue.Controls.Count == 1) { string value = _attribute.FieldType.Field.GetEditValue(phEditValue.Controls[0], _attribute.QualifierValues); var attributeValueService = new AttributeValueService(); var attributeValue = attributeValueService.Get(( int )e.Keys["Id"]); if (attributeValue == null) { attributeValue = new AttributeValue(); attributeValueService.Add(attributeValue, _currentPersonId); attributeValue.AttributeId = _attribute.Id; attributeValue.EntityId = _model.Id; } attributeValue.Value = value; attributeValueService.Save(attributeValue, _currentPersonId); _model.LoadAttributes(); } lvAttributeValues.EditIndex = -1; BindData(); }
void lvAttributeValues_ItemDeleting(object sender, ListViewDeleteEventArgs e) { var attributeValueService = new AttributeValueService(); var attributeValue = attributeValueService.Get(( int )e.Keys["Id"]); if (attributeValue != null) { attributeValueService.Delete(attributeValue, _currentPersonId); attributeValueService.Save(attributeValue, _currentPersonId); _model.LoadAttributes(); } BindData(); }
/// <summary> /// Deletes the attribute value. /// </summary> /// <param name="attributeValueGuid">The attribute value unique identifier.</param> public static void DeleteAttributeValue(Guid attributeValueGuid) { using (var rockContext = new RockContext()) { var attributeValueService = new AttributeValueService(rockContext); var attributeValue = attributeValueService.Get(attributeValueGuid); if (attributeValue == null) { return; } attributeValueService.Delete(attributeValue); rockContext.SaveChanges(); } }
void lvAttributeValues_ItemUpdating( object sender, ListViewUpdateEventArgs e ) { PlaceHolder phEditValue = lvAttributeValues.EditItem.FindControl( "phEditValue" ) as PlaceHolder; if ( phEditValue != null && phEditValue.Controls.Count == 1 ) { string value = _attribute.FieldType.Field.ReadValue( phEditValue.Controls[0] ); var attributeValueService = new AttributeValueService(); var attributeValue = attributeValueService.Get( ( int )e.Keys["Id"] ); if ( attributeValue == null ) { attributeValue = new AttributeValue(); attributeValueService.Add( attributeValue, _currentPersonId ); attributeValue.AttributeId = _attribute.Id; attributeValue.EntityId = _model.Id; } attributeValue.Value = value; attributeValueService.Save( attributeValue, _currentPersonId ); Rock.Attribute.Helper.LoadAttributes( _model ); } lvAttributeValues.EditIndex = -1; BindData(); }
void lvAttributeValues_ItemDeleting( object sender, ListViewDeleteEventArgs e ) { var attributeValueService = new AttributeValueService(); var attributeValue = attributeValueService.Get( ( int )e.Keys["Id"] ); if ( attributeValue != null ) { attributeValueService.Delete( attributeValue, _currentPersonId ); attributeValueService.Save( attributeValue, _currentPersonId ); Rock.Attribute.Helper.LoadAttributes( _model ); } BindData(); }