Merge pull request #5173 from kjac/v8-fix-create-content-type-with-template

V8: YSOD when creating the same content type twice (mapping issue)
This commit is contained in:
Stephan
2019-04-05 19:05:23 +02:00
committed by GitHub

View File

@@ -246,7 +246,13 @@ namespace Umbraco.Web.Models.Mapping
{
var templates = _fileService.GetTemplates(source.AllowedTemplates.ToArray());
target.AllowedTemplates = source.AllowedTemplates
.Select(x => context.Mapper.Map<EntityBasic>(templates.SingleOrDefault(t => t.Alias == x)))
.Select(x =>
{
var template = templates.SingleOrDefault(t => t.Alias == x);
return template != null
? context.Mapper.Map<EntityBasic>(template)
: null;
})
.WhereNotNull()
.ToArray();
}