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.
87 lines
2.7 KiB
87 lines
2.7 KiB
// ==========================================================================
|
|
// SchemaFieldsController.cs
|
|
// PinkParrot Headless CMS
|
|
// ==========================================================================
|
|
// Copyright (c) PinkParrot Group
|
|
// All rights reserved.
|
|
// ==========================================================================
|
|
|
|
using System.Threading.Tasks;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using PinkParrot.Infrastructure.CQRS.Commands;
|
|
using PinkParrot.Infrastructure.Reflection;
|
|
using PinkParrot.Write.Schemas.Commands;
|
|
|
|
namespace PinkParrot.Modules.Api.Schemas
|
|
{
|
|
public class SchemasFieldsController : ControllerBase
|
|
{
|
|
public SchemasFieldsController(ICommandBus commandBus)
|
|
: base(commandBus)
|
|
{
|
|
}
|
|
|
|
[HttpPost]
|
|
[Route("api/schemas/{name}/fields/")]
|
|
public Task Add(string name, [FromBody] CreateFieldDto model)
|
|
{
|
|
var command = SimpleMapper.Map(model, new AddField());
|
|
|
|
return CommandBus.PublishAsync(command);
|
|
}
|
|
|
|
[HttpPut]
|
|
[Route("api/schemas/{name}/fields/{fieldId:long}/")]
|
|
public Task Update(string name, long fieldId, [FromBody] UpdateFieldDto model)
|
|
{
|
|
var command = new UpdateField { FieldId = fieldId, Properties = model.Properties };
|
|
|
|
return CommandBus.PublishAsync(command);
|
|
}
|
|
|
|
[HttpPut]
|
|
[Route("api/schemas/{name}/fields/{fieldId:long}/hide/")]
|
|
public Task Hide(string name, long fieldId)
|
|
{
|
|
var command = new HideField { FieldId = fieldId };
|
|
|
|
return CommandBus.PublishAsync(command);
|
|
}
|
|
|
|
[HttpPut]
|
|
[Route("api/schemas/{name}/fields/{fieldId:long}/show/")]
|
|
public Task Show(string name, long fieldId)
|
|
{
|
|
var command = new ShowField { FieldId = fieldId };
|
|
|
|
return CommandBus.PublishAsync(command);
|
|
}
|
|
|
|
[HttpPut]
|
|
[Route("api/schemas/{name}/fields/{fieldId:long}/enable/")]
|
|
public Task Enable(string name, long fieldId)
|
|
{
|
|
var command = new EnableField { FieldId = fieldId };
|
|
|
|
return CommandBus.PublishAsync(command);
|
|
}
|
|
|
|
[HttpPut]
|
|
[Route("api/schemas/{name}/fields/{fieldId:long}/disable/")]
|
|
public Task Disable(string name, long fieldId)
|
|
{
|
|
var command = new DisableField { FieldId = fieldId };
|
|
|
|
return CommandBus.PublishAsync(command);
|
|
}
|
|
|
|
[HttpDelete]
|
|
[Route("api/schemas/{name}/fields/{fieldId:long}/")]
|
|
public Task Delete(string name, long fieldId)
|
|
{
|
|
var command = new DeleteField { FieldId = fieldId };
|
|
|
|
return CommandBus.PublishAsync(command);
|
|
}
|
|
}
|
|
}
|