mirror of https://github.com/Squidex/squidex.git
11 changed files with 160 additions and 58 deletions
@ -0,0 +1,49 @@ |
|||
// ==========================================================================
|
|||
// Squidex Headless CMS
|
|||
// ==========================================================================
|
|||
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
|||
// All rights reserved. Licensed under the MIT license.
|
|||
// ==========================================================================
|
|||
|
|||
using System.Collections.Generic; |
|||
using System.ComponentModel.DataAnnotations; |
|||
using System.Linq; |
|||
using Squidex.Domain.Apps.Entities.Backup; |
|||
using Squidex.Shared; |
|||
using Squidex.Web; |
|||
|
|||
namespace Squidex.Areas.Api.Controllers.Backups.Models |
|||
{ |
|||
public sealed class BackupJobsDto : Resource |
|||
{ |
|||
/// <summary>
|
|||
/// The backups.
|
|||
/// </summary>
|
|||
[Required] |
|||
public BackupJobDto[] Items { get; set; } |
|||
|
|||
public static BackupJobsDto FromBackups(IEnumerable<IBackupJob> backups, ApiController controller, string app) |
|||
{ |
|||
var result = new BackupJobsDto |
|||
{ |
|||
Items = backups.Select(x => BackupJobDto.FromBackup(x, controller, app)).ToArray() |
|||
}; |
|||
|
|||
return CreateLinks(result, controller, app); |
|||
} |
|||
|
|||
private static BackupJobsDto CreateLinks(BackupJobsDto result, ApiController controller, string app) |
|||
{ |
|||
var values = new { app }; |
|||
|
|||
result.AddSelfLink(controller.Url<BackupsController>(x => nameof(x.GetBackups), values)); |
|||
|
|||
if (controller.HasPermission(Permissions.AppBackupsCreate, app)) |
|||
{ |
|||
result.AddPostLink("create", controller.Url<BackupsController>(x => nameof(x.PostBackup), values)); |
|||
} |
|||
|
|||
return result; |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue