U4-4629 - Detecting existing macros

By setting the ID of the macro the repository layer will update the existing instance rather than trying to create a new one, which would result in a duplicate alias and that violates a table index.
This commit is contained in:
Aaron Powell
2014-04-07 18:10:09 +10:00
parent 08d74e3320
commit f45edbe2fe

View File

@@ -1196,6 +1196,10 @@ namespace Umbraco.Core.Services
foreach (var macro in macros)
{
var existing = _macroService.GetByAlias(macro.Alias);
if (existing != null)
macro.Id = existing.Id;
_macroService.Save(macro, userId);
}
@@ -1820,4 +1824,4 @@ namespace Umbraco.Core.Services
public static event TypedEventHandler<IPackagingService, ExportEventArgs<ITemplate>> ExportedTemplate;
#endregion
}
}
}