// ========================================================================== // Squidex Headless CMS // ========================================================================== // Copyright (c) Squidex UG (haftungsbeschraenkt) // All rights reserved. Licensed under the MIT license. // ========================================================================== using System; using Microsoft.AspNetCore.Mvc; using Squidex.Domain.Apps.Core.Contents; using Squidex.Domain.Apps.Entities.Contents.Commands; using Squidex.Infrastructure; using StatusType = Squidex.Domain.Apps.Core.Contents.Status; namespace Squidex.Areas.Api.Controllers.Contents.Models { public class CreateContentDto { /// /// The full data for the content item. /// [FromBody] public ContentData Data { get; set; } /// /// The initial status. /// [FromQuery] public StatusType? Status { get; set; } /// /// The optional custom content id. /// [FromQuery] public DomainId? Id { get; set; } /// /// True to automatically publish the content. /// [FromQuery] [Obsolete("Use 'status' query string now.")] public bool Publish { get; set; } public CreateContent ToCommand() { var command = new CreateContent { Data = Data! }; if (Id != null && Id.Value != default && !string.IsNullOrWhiteSpace(Id.Value.ToString())) { command.ContentId = Id.Value; } if (Status != null) { command.Status = Status; } #pragma warning disable CS0618 // Type or member is obsolete else if (Publish) { command.Status = StatusType.Published; } #pragma warning restore CS0618 // Type or member is obsolete return command; } } }