fixed NestedContentController to use pattern matching instead of equals operator

This commit is contained in:
Zeegaan
2021-09-21 13:25:11 +02:00
parent ae85c959d4
commit a7d60badd3
2 changed files with 3 additions and 35 deletions

View File

@@ -4,6 +4,7 @@
using System.Collections.Generic;
using System.Linq;
using Microsoft.AspNetCore.Mvc;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Web.BackOffice.Controllers;
using Umbraco.Cms.Web.Common.Attributes;
@@ -23,9 +24,7 @@ namespace Umbraco.Cms.Web.BackOffice.PropertyEditors
}
[HttpGet]
public IEnumerable<object> GetContentTypes()
{
return _contentTypeService
public IEnumerable<object> GetContentTypes() => _contentTypeService
.GetAllElementTypes()
.OrderBy(x => x.SortOrder)
.Select(x => new
@@ -35,8 +34,7 @@ namespace Umbraco.Cms.Web.BackOffice.PropertyEditors
name = x.Name,
alias = x.Alias,
icon = x.Icon,
tabs = x.CompositionPropertyGroups.Select(y => y.Name).Distinct()
tabs = x.CompositionPropertyGroups.Where(x => x.Type == PropertyGroupType.Group && x.GetParentAlias() is null).Select(y => y.Name).Distinct()
});
}
}
}

View File

@@ -1,30 +0,0 @@
using System.Collections.Generic;
using System.Linq;
using Umbraco.Core.Models;
using Umbraco.Core.Services;
using Umbraco.Web.Editors;
using Umbraco.Web.Mvc;
namespace Umbraco.Web.PropertyEditors
{
[PluginController("UmbracoApi")]
public class NestedContentController : UmbracoAuthorizedJsonController
{
[System.Web.Http.HttpGet]
public IEnumerable<object> GetContentTypes()
{
return Services.ContentTypeService
.GetAllElementTypes()
.OrderBy(x => x.SortOrder)
.Select(x => new
{
id = x.Id,
guid = x.Key,
name = x.Name,
alias = x.Alias,
icon = x.Icon,
tabs = x.CompositionPropertyGroups.Where(x => x.Type == PropertyGroupType.Group && x.GetParentAlias() == null).Select(y => y.Name).Distinct()
});
}
}
}