try rewirte of all backoffice controllers to ApiControllers
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using zero.Core.Api;
|
||||
using zero.Core.Entities;
|
||||
using zero.Core.Extensions;
|
||||
using zero.Core.Identity;
|
||||
using zero.Web.Models;
|
||||
|
||||
namespace zero.Web.Controllers
|
||||
{
|
||||
@@ -11,58 +13,34 @@ namespace zero.Web.Controllers
|
||||
public class ApplicationsController : BackofficeController
|
||||
{
|
||||
IApplicationsApi Api;
|
||||
IApplication Blueprint;
|
||||
|
||||
public ApplicationsController(IApplicationsApi api, IApplication blueprint)
|
||||
public ApplicationsController(IApplicationsApi api)
|
||||
{
|
||||
Api = api;
|
||||
Blueprint = blueprint;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Get translation by id
|
||||
/// </summary>
|
||||
public IActionResult GetEmpty() => Edit(Blueprint.Clone());
|
||||
public EditModel<IApplication> GetEmpty([FromServices] IApplication blueprint) => Edit(blueprint);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Get translation by id
|
||||
/// </summary>
|
||||
public async Task<IActionResult> GetById([FromQuery] string id) => Edit(await Api.GetById(id));
|
||||
public async Task<EditModel<IApplication>> GetById([FromQuery] string id) => Edit(await Api.GetById(id));
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Get all translations
|
||||
/// </summary>
|
||||
public async Task<IActionResult> GetAll([FromQuery] ListQuery<IApplication> query = null)
|
||||
{
|
||||
if (query == null)
|
||||
{
|
||||
return Json(await Api.GetAll());
|
||||
}
|
||||
|
||||
return Json(await Api.GetByQuery(query));
|
||||
}
|
||||
public async Task<IList<IApplication>> GetAll() => await Api.GetAll();
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Get all available features to select
|
||||
/// </summary>
|
||||
public IActionResult GetAllFeatures() => Json(Options.Features.GetAllItems());
|
||||
public async Task<ListResult<IApplication>> GetByQuery([FromQuery] ListQuery<IApplication> query) => await Api.GetByQuery(query);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Save translation
|
||||
/// </summary>
|
||||
public IReadOnlyCollection<IFeature> GetAllFeatures() => Options.Features.GetAllItems();
|
||||
|
||||
|
||||
[HttpPost]
|
||||
[ZeroAuthorize(Permissions.Settings.Applications, PermissionsValue.Update)]
|
||||
public async Task<IActionResult> Save([FromBody] IApplication model) => Json(await Api.Save(model));
|
||||
public async Task<EntityResult<IApplication>> Save([FromBody] IApplication model) => await Api.Save(model);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Deletes a translation
|
||||
/// </summary>
|
||||
[HttpDelete]
|
||||
[ZeroAuthorize(Permissions.Settings.Applications, PermissionsValue.Update)]
|
||||
public async Task<IActionResult> Delete([FromQuery] string id) => Json(await Api.Delete(id));
|
||||
public async Task<EntityResult<IApplication>> Delete([FromQuery] string id) => await Api.Delete(id);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user