/// <summary> /// To the model. /// </summary> /// <param name="value">The value.</param> /// <returns></returns> public static Attribute ToModel(this AttributeDto value) { Attribute result = new Attribute(); value.CopyToModel(result); return(result); }
/// <summary> /// Adds the block attribute. /// </summary> /// <param name="blockGuid">The block GUID.</param> /// <param name="fieldTypeGuid">The field type GUID.</param> /// <param name="attribute">The attribute.</param> public void AddBlockAttribute(string blockGuid, string fieldTypeGuid, Rock.Model.AttributeDto attribute) { AddBlockTypeAttribute(blockGuid, fieldTypeGuid, attribute.Name, attribute.Key, attribute.Category, attribute.Description, attribute.Order, attribute.DefaultValue, attribute.Guid.ToString()); string updateSql = "Update [Attribute] set [IsGridColumn] = {0}, [IsMultiValue] = {1}, [IsRequired] = {2} where Guid = '{3}'"; Sql(string.Format(updateSql, attribute.IsGridColumn.Bit(), attribute.IsMultiValue.Bit(), attribute.IsRequired.Bit(), attribute.Guid.ToString())); }
public Rock.Model.AttributeDto DefaultBlockAttribute(string name, string category, string description, int order, string defaultValue, Guid guid) { var attribute = new Rock.Model.AttributeDto(); attribute.IsSystem = true; attribute.Key = name.Replace(" ", string.Empty); attribute.Name = name; attribute.Category = category; attribute.Description = description; attribute.Order = order; attribute.Guid = guid; return(attribute); }
public void AddBlockAttribute(string blockGuid, string fieldTypeGuid, Rock.Model.AttributeDto attribute) { Sql(string.Format(@" DECLARE @BlockTypeId int SET @BlockTypeId = (SELECT [Id] FROM [BlockType] WHERE [Guid] = '{0}') DECLARE @FieldTypeId int SET @FieldTypeId = (SELECT [Id] FROM [FieldType] WHERE [Guid] = '{1}') -- Delete existing attribute first (might have been created by Rock system) DELETE [Attribute] WHERE [Entity] = 'Rock.Model.Block' AND [EntityQualifierColumn] = 'BlockTypeId' AND [EntityQualifierValue] = CAST(@BlockTypeId as varchar) AND [Key] = '{2}' INSERT INTO [Attribute] ( [IsSystem],[FieldTypeId],[Entity],[EntityQualifierColumn],[EntityQualifierValue], [Key],[Name],[Category],[Description], [Order],[IsGridColumn],[DefaultValue],[IsMultiValue],[IsRequired], [Guid]) VALUES( 1,@FieldTypeId,'Rock.Model.Block','BlockTypeId',CAST(@BlockTypeId as varchar), '{2}','{3}','{4}','{5}', {6},{7},'{8}',{9},{10}, '{11}') ", blockGuid, fieldTypeGuid, attribute.Key, attribute.Name, attribute.Category, attribute.Description.Replace("'", "''"), attribute.Order, attribute.IsGridColumn.Bit(), attribute.DefaultValue, attribute.IsMultiValue.Bit(), attribute.IsRequired.Bit(), attribute.Guid) ); }