mirror of https://github.com/Squidex/squidex.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
1.8 KiB
54 lines
1.8 KiB
// ==========================================================================
|
|
// Squidex Headless CMS
|
|
// ==========================================================================
|
|
// Copyright (c) Squidex UG (haftungsbeschränkt)
|
|
// All rights reserved. Licensed under the MIT license.
|
|
// ==========================================================================
|
|
|
|
using System.ComponentModel.DataAnnotations;
|
|
using System.Linq;
|
|
using Squidex.Domain.Apps.Entities.Assets;
|
|
using Squidex.Infrastructure;
|
|
using Squidex.Web;
|
|
|
|
namespace Squidex.Areas.Api.Controllers.Assets.Models
|
|
{
|
|
public sealed class AssetFoldersDto : Resource
|
|
{
|
|
/// <summary>
|
|
/// The total number of assets.
|
|
/// </summary>
|
|
public long Total { get; set; }
|
|
|
|
/// <summary>
|
|
/// The assets folders.
|
|
/// </summary>
|
|
[Required]
|
|
public AssetFolderDto[] Items { get; set; }
|
|
|
|
public static AssetFoldersDto FromAssets(IResultList<IAssetFolderEntity> assetFolders, Resources resources)
|
|
{
|
|
var response = new AssetFoldersDto
|
|
{
|
|
Total = assetFolders.Total,
|
|
Items = assetFolders.Select(x => AssetFolderDto.FromAssetFolder(x, resources)).ToArray()
|
|
};
|
|
|
|
return CreateLinks(response, resources);
|
|
}
|
|
|
|
private static AssetFoldersDto CreateLinks(AssetFoldersDto response, Resources resources)
|
|
{
|
|
var values = new { app = resources.App };
|
|
|
|
response.AddSelfLink(resources.Url<AssetFoldersController>(x => nameof(x.GetAssetFolders), values));
|
|
|
|
if (resources.CanUpdateAsset)
|
|
{
|
|
response.AddPostLink("create", resources.Url<AssetFoldersController>(x => nameof(x.PostAssetFolder), values));
|
|
}
|
|
|
|
return response;
|
|
}
|
|
}
|
|
}
|
|
|