public Macro AddProperty(string alias, string name, string type, int sortOrder = 0) { Log.DebugFormat("Adding property to Macro of type {0} with alias `{1}` and name `{2}`, ", type, alias, name); var propertyTypes = MacroPropertyType.GetAll; var propertyType = propertyTypes.Single(x => x.Alias.Equals(type, StringComparison.InvariantCulture)); var propertyDto = new MacroPropertyDto { Alias = alias, Name = name, Macro = _macroDto.Id, SortOrder = (byte)sortOrder, Type = (short)propertyType.Id }; UmbracoDatabase.Save(propertyDto); return(this); }
private List <MacroPropertyDto> BuildPropertyDtos(IMacro entity) { var list = new List <MacroPropertyDto>(); foreach (var p in entity.Properties) { var text = new MacroPropertyDto { Alias = p.Alias, Name = p.Name, Macro = entity.Id, SortOrder = (byte)p.SortOrder, EditorAlias = p.EditorAlias, Id = p.Id }; list.Add(text); } return(list); }
internal MacroDto Map(MacroDto a, MacroPropertyDto p) { // Terminating call. Since we can return null from this function // we need to be ready for PetaPoco to callback later with null // parameters if (a == null) { return(Current); } // Is this the same DictionaryItem as the current one we're processing if (Current != null && Current.Id == a.Id) { // Yes, just add this MacroPropertyDtos to the current item's collection Current.MacroPropertyDtos.Add(p); // Return null to indicate we're not done with this Macro yet return(null); } // This is a different Macro to the current one, or this is the // first time through and we don't have one yet // Save the current Macro var prev = Current; // Setup the new current Macro Current = a; Current.MacroPropertyDtos = new List <MacroPropertyDto>(); //this can be null since we are doing a left join if (p.Alias != null) { Current.MacroPropertyDtos.Add(p); } // Return the now populated previous Macro (or null if first time through) return(prev); }