Files
mixtape/zero.Web/Controllers/PagesController.cs
T

45 lines
1.2 KiB
C#
Raw Normal View History

2020-05-19 15:53:01 +02:00
using Microsoft.AspNetCore.Mvc;
using System.Threading.Tasks;
using zero.Core.Api;
2020-05-25 11:27:23 +02:00
using zero.Core.Entities;
2020-05-19 15:53:01 +02:00
namespace zero.Web.Controllers
{
public class PagesController<T> : BackofficeController where T : IPage, new()
2020-05-19 15:53:01 +02:00
{
2020-05-25 11:27:23 +02:00
IPagesApi<T> Api;
2020-05-19 15:53:01 +02:00
2020-05-25 11:27:23 +02:00
public PagesController(IPagesApi<T> api)
2020-05-19 15:53:01 +02:00
{
Api = api;
}
2020-07-08 13:59:46 +02:00
public async Task<ActionResult> GetAllowedPageTypes([FromQuery] string parent = null) => Json(await Api.GetAllowedPageTypes(parent));
public IActionResult GetPageType([FromQuery] string alias) => Json(Api.GetPageType(alias));
2020-05-25 11:27:23 +02:00
public async Task<IActionResult> GetById([FromQuery] string id) => Edit(await Api.GetById(id));
2020-07-08 13:59:46 +02:00
public IActionResult GetEmpty(string type, string parent = null) => Edit(new T()
{
PageTypeAlias = type,
ParentId = parent
});
2020-07-08 13:59:46 +02:00
public async Task<IActionResult> Save([FromBody] T model) => Json(await Api.Save(model));
2020-08-13 14:58:01 +02:00
[HttpPost]
public async Task<IActionResult> SaveSorting([FromBody] string[] ids) => Json(await Api.SaveSorting(ids));
2020-08-13 15:55:59 +02:00
[HttpPost]
public async Task<IActionResult> Move([FromBody] T model) => Json(await Api.Move(model.Id, model.ParentId));
2020-07-08 13:59:46 +02:00
public async Task<IActionResult> Delete([FromQuery] string id) => Json(await Api.Delete(id));
2020-05-19 15:53:01 +02:00
}
}