try rewirte of all backoffice controllers to ApiControllers
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using zero.Core.Api;
|
||||
using zero.Core.Entities;
|
||||
@@ -20,18 +21,18 @@ namespace zero.Web.Controllers
|
||||
}
|
||||
|
||||
|
||||
public async Task<ActionResult> GetAllowedPageTypes([FromQuery] string parent = null) => Json(await Api.GetAllowedPageTypes(parent));
|
||||
public async Task<IList<PageType>> GetAllowedPageTypes([FromQuery] string parent = null) => await Api.GetAllowedPageTypes(parent);
|
||||
|
||||
|
||||
public IActionResult GetPageType([FromQuery] string alias) => Json(Api.GetPageType(alias));
|
||||
public PageType GetPageType([FromQuery] string alias) => Api.GetPageType(alias);
|
||||
|
||||
public async Task<IActionResult> GetById([FromQuery] string id)
|
||||
public async Task<PageEditModel<IPage>> GetById([FromQuery] string id)
|
||||
{
|
||||
IPage entity = await Api.GetById(id);
|
||||
|
||||
if (entity == null)
|
||||
{
|
||||
return NotFound();
|
||||
return null;
|
||||
}
|
||||
|
||||
return Edit<IPage, PageEditModel<IPage>>(new PageEditModel<IPage>()
|
||||
@@ -42,7 +43,8 @@ namespace zero.Web.Controllers
|
||||
});
|
||||
}
|
||||
|
||||
public IActionResult GetEmpty(string type, string parent = null)
|
||||
|
||||
public EditModel<IPage> GetEmpty(string type, string parent = null)
|
||||
{
|
||||
PageType pageType = Api.GetPageType(type);
|
||||
IPage model = Activator.CreateInstance(pageType.ContentType) as IPage;
|
||||
@@ -53,22 +55,29 @@ namespace zero.Web.Controllers
|
||||
return Edit(model);
|
||||
}
|
||||
|
||||
public async Task<IActionResult> GetRevisions([FromQuery] string id, [FromQuery] int page = 1) => Json(await RevisionsApi.GetPaged<IPage>(id, page));
|
||||
|
||||
public async Task<IActionResult> Save([FromBody] IPage model) => Json(await Api.Save(model));
|
||||
public async Task<ListResult<Revision>> GetRevisions([FromQuery] string id, [FromQuery] int page = 1) => await RevisionsApi.GetPaged<IPage>(id, page);
|
||||
|
||||
|
||||
public async Task<EntityResult<IPage>> Save([FromBody] IPage model) => await Api.Save(model);
|
||||
|
||||
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> SaveSorting([FromBody] string[] ids) => Json(await Api.SaveSorting(ids));
|
||||
public async Task<EntityResult<IList<IPage>>> SaveSorting([FromBody] string[] ids) => await Api.SaveSorting(ids);
|
||||
|
||||
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> Move([FromBody] ActionCopyModel model) => Json(await Api.Move(model.Id, model.DestinationId));
|
||||
public async Task<EntityResult<IPage>> Move([FromBody] ActionCopyModel model) => await Api.Move(model.Id, model.DestinationId);
|
||||
|
||||
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> Copy([FromBody] ActionCopyModel model) => Json(await Api.Copy(model.Id, model.DestinationId, model.IncludeDescendants));
|
||||
public async Task<EntityResult<IPage>> Copy([FromBody] ActionCopyModel model) => await Api.Copy(model.Id, model.DestinationId, model.IncludeDescendants);
|
||||
|
||||
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> Restore([FromBody] ActionCopyModel model) => Json(await Api.Restore(model.Id, model.IncludeDescendants));
|
||||
public async Task<EntityResult<string[]>> Restore([FromBody] ActionCopyModel model) => await Api.Restore(model.Id, model.IncludeDescendants);
|
||||
|
||||
public async Task<IActionResult> Delete([FromQuery] string id) => Json(await Api.Delete(id, true));
|
||||
|
||||
public async Task<EntityResult<string[]>> Delete([FromQuery] string id) => await Api.Delete(id, true);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user