mirror of https://github.com/Squidex/squidex.git
22 changed files with 273 additions and 245 deletions
@ -1,59 +0,0 @@ |
|||||
// ==========================================================================
|
|
||||
// Squidex Headless CMS
|
|
||||
// ==========================================================================
|
|
||||
// Copyright (c) Squidex UG (haftungsbeschränkt)
|
|
||||
// All rights reserved. Licensed under the MIT license.
|
|
||||
// ==========================================================================
|
|
||||
|
|
||||
using System; |
|
||||
using System.ComponentModel.DataAnnotations; |
|
||||
using System.Linq; |
|
||||
using Squidex.Domain.Apps.Core.Apps; |
|
||||
using Squidex.Domain.Apps.Entities.Apps.Services; |
|
||||
using Squidex.Infrastructure.Commands; |
|
||||
|
|
||||
namespace Squidex.Areas.Api.Controllers.Apps.Models |
|
||||
{ |
|
||||
public sealed class AppCreatedDto |
|
||||
{ |
|
||||
/// <summary>
|
|
||||
/// Id of the created entity.
|
|
||||
/// </summary>
|
|
||||
[Required] |
|
||||
public string Id { get; set; } |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// The permission level of the user.
|
|
||||
/// </summary>
|
|
||||
public string[] Permissions { get; set; } |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// The new version of the entity.
|
|
||||
/// </summary>
|
|
||||
public long Version { get; set; } |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// Gets the current plan name.
|
|
||||
/// </summary>
|
|
||||
public string PlanName { get; set; } |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// Gets the next plan name.
|
|
||||
/// </summary>
|
|
||||
public string PlanUpgrade { get; set; } |
|
||||
|
|
||||
public static AppCreatedDto FromResult(string name, EntityCreatedResult<Guid> result, IAppPlansProvider apps) |
|
||||
{ |
|
||||
var response = new AppCreatedDto |
|
||||
{ |
|
||||
Id = result.IdOrValue.ToString(), |
|
||||
Permissions = Role.CreateOwner(name).Permissions.ToIds().ToArray(), |
|
||||
PlanName = apps.GetPlan(null)?.Name, |
|
||||
PlanUpgrade = apps.GetPlanUpgrade(null)?.Name, |
|
||||
Version = result.Version |
|
||||
}; |
|
||||
|
|
||||
return response; |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -0,0 +1,38 @@ |
|||||
|
// ==========================================================================
|
||||
|
// Squidex Headless CMS
|
||||
|
// ==========================================================================
|
||||
|
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
||||
|
// All rights reserved. Licensed under the MIT license.
|
||||
|
// ==========================================================================
|
||||
|
|
||||
|
using System.ComponentModel.DataAnnotations; |
||||
|
using System.Linq; |
||||
|
using Squidex.Domain.Apps.Entities.Apps; |
||||
|
using Squidex.Web; |
||||
|
|
||||
|
namespace Squidex.Areas.Api.Controllers.Apps.Models |
||||
|
{ |
||||
|
public sealed class ClientsDto : Resource |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// The clients.
|
||||
|
/// </summary>
|
||||
|
[Required] |
||||
|
public ClientDto[] Items { get; set; } |
||||
|
|
||||
|
public static ClientsDto FromApp(IAppEntity app, ApiController controller) |
||||
|
{ |
||||
|
var result = new ClientsDto |
||||
|
{ |
||||
|
Items = app.Clients.Select(x => ClientDto.FromClient(x.Key, x.Value, controller, app.Name)).ToArray() |
||||
|
}; |
||||
|
|
||||
|
return CreateLinks(result, controller, app.Name); |
||||
|
} |
||||
|
|
||||
|
private static ClientsDto CreateLinks(ClientsDto result, ApiController controller, string app) |
||||
|
{ |
||||
|
return result; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue