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.
47 lines
1.5 KiB
47 lines
1.5 KiB
// ==========================================================================
|
|
// Squidex Headless CMS
|
|
// ==========================================================================
|
|
// Copyright (c) Squidex UG (haftungsbeschränkt)
|
|
// All rights reserved. Licensed under the MIT license.
|
|
// ==========================================================================
|
|
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel.DataAnnotations;
|
|
using System.Linq;
|
|
using Squidex.Domain.Apps.Entities.Rules;
|
|
using Squidex.Web;
|
|
|
|
namespace Squidex.Areas.Api.Controllers.Rules.Models
|
|
{
|
|
public sealed class RuleEventsDto : Resource
|
|
{
|
|
/// <summary>
|
|
/// The rule events.
|
|
/// </summary>
|
|
[Required]
|
|
public RuleEventDto[] Items { get; set; }
|
|
|
|
/// <summary>
|
|
/// The total number of rule events.
|
|
/// </summary>
|
|
public long Total { get; set; }
|
|
|
|
public static RuleEventsDto FromRuleEvents(IReadOnlyList<IRuleEventEntity> items, long total, ApiController controller, string app)
|
|
{
|
|
var result = new RuleEventsDto
|
|
{
|
|
Total = total,
|
|
Items = items.Select(x => RuleEventDto.FromRuleEvent(x, controller, app)).ToArray()
|
|
};
|
|
|
|
return result.CreateLinks(controller, app);
|
|
}
|
|
|
|
private RuleEventsDto CreateLinks(ApiController controller, string app)
|
|
{
|
|
AddSelfLink(controller.Url<RulesController>(x => nameof(x.GetEvents), new { app }));
|
|
|
|
return this;
|
|
}
|
|
}
|
|
}
|
|
|