Adss null check

This commit is contained in:
Warren Buckley
2017-04-24 14:57:57 +01:00
parent d6272b0cdb
commit 7ee0a278f7

View File

@@ -135,21 +135,26 @@ namespace Umbraco.Web.Editors
var templateHasChildren = Services.FileService.GetTemplateDescendants(display.Id);
foreach (var childTemplate in templateHasChildren)
{
{
//template ID to find
var templateIDInPath = "," + display.Id + ",";
var templateIdInPath = "," + display.Id + ",";
if (string.IsNullOrEmpty(childTemplate.Path))
{
continue;
}
//Find position in current comma seperate string path (so we get the correct children path)
var positionInPath = childTemplate.Path.IndexOf(templateIDInPath) + templateIDInPath.Length;
var positionInPath = childTemplate.Path.IndexOf(templateIdInPath) + templateIdInPath.Length;
//Get the substring of the child & any children (descendants it may have too)
var childTemplatePath = childTemplate.Path.Substring(positionInPath);
//As we are updating the template to be a child of a master
var childTemplatePath = childTemplate.Path.Substring(positionInPath);
//As we are updating the template to be a child of a master
//Set the path to the master's path + its current template id + the current child path substring
childTemplate.Path = master.Path + "," + display.Id + "," + childTemplatePath;
//Save the children with the updated path
childTemplate.Path = master.Path + "," + display.Id + "," + childTemplatePath;
//Save the children with the updated path
Services.FileService.SaveTemplate(childTemplate);
}
}