* Rework language service and API * Revert unintended commit of Directory.Build.props * Create OS conditional test for invalid ISO codes * Reintroduce and obsolete old Delete method on ILocalizationService + make new Delete method delete by ISO code + add obsoletion attrs to service implementation * Review comments + utilize new Delete method * Do not allow model reuse when creating a new language * Fix bad merge * Split localization service into dedicated services for language and dictionary item handling * Replaced ILocalizationService usage in management API (as much as can be done for now) * Ensure we can create dictionary items with explicit keys (but no duplicates) * Fix culture controller so it works properly with pagination * Update OpenAPI JSON * Actually update the language being updated... * Unit test for invalid ISO now no longer needs to differ between OS :) * A little bit of code health improvements * A litte less code duplication * Remove duplicate validation
40 lines
1.5 KiB
C#
40 lines
1.5 KiB
C#
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Umbraco.Cms.Core.Models;
|
|
using Umbraco.Cms.Core.Services;
|
|
using Umbraco.Cms.Api.Management.Services.Paging;
|
|
using Umbraco.Cms.Api.Common.ViewModels.Pagination;
|
|
using Umbraco.Cms.Api.Management.ViewModels.Tree;
|
|
|
|
namespace Umbraco.Cms.Api.Management.Controllers.Dictionary.Tree;
|
|
|
|
public class ChildrenDictionaryTreeController : DictionaryTreeControllerBase
|
|
{
|
|
public ChildrenDictionaryTreeController(IEntityService entityService, IDictionaryItemService dictionaryItemService)
|
|
: base(entityService, dictionaryItemService)
|
|
{
|
|
}
|
|
|
|
[HttpGet("children")]
|
|
[MapToApiVersion("1.0")]
|
|
[ProducesResponseType(typeof(PagedViewModel<EntityTreeItemViewModel>), StatusCodes.Status200OK)]
|
|
public async Task<ActionResult<PagedViewModel<EntityTreeItemViewModel>>> Children(Guid parentKey, int skip = 0, int take = 100)
|
|
{
|
|
if (PaginationService.ConvertSkipTakeToPaging(skip, take, out var pageNumber, out var pageSize, out ProblemDetails? error) == false)
|
|
{
|
|
return BadRequest(error);
|
|
}
|
|
|
|
IDictionaryItem[] dictionaryItems = PaginatedDictionaryItems(
|
|
pageNumber,
|
|
pageSize,
|
|
await DictionaryItemService.GetChildrenAsync(parentKey),
|
|
out var totalItems);
|
|
|
|
EntityTreeItemViewModel[] viewModels = await MapTreeItemViewModels(null, dictionaryItems);
|
|
|
|
PagedViewModel<EntityTreeItemViewModel> result = PagedViewModel(viewModels, totalItems);
|
|
return await Task.FromResult(Ok(result));
|
|
}
|
|
}
|