2020-05-04 14:13:03 +02:00
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using zero.Core.Api;
|
|
|
|
|
using zero.Core.Entities;
|
|
|
|
|
using zero.Core.Identity;
|
2020-10-27 15:47:23 +01:00
|
|
|
using zero.Web.Models;
|
2020-05-04 14:13:03 +02:00
|
|
|
|
|
|
|
|
namespace zero.Web.Controllers
|
|
|
|
|
{
|
|
|
|
|
[ZeroAuthorize(Permissions.Settings.Translations, PermissionsValue.Read)]
|
2020-08-27 16:12:47 +02:00
|
|
|
public class TranslationsController : BackofficeController
|
2020-05-04 14:13:03 +02:00
|
|
|
{
|
2020-08-27 16:12:47 +02:00
|
|
|
ITranslationsApi Api;
|
2020-05-04 14:13:03 +02:00
|
|
|
|
2020-10-27 15:47:23 +01:00
|
|
|
public TranslationsController(ITranslationsApi api)
|
2020-05-04 14:13:03 +02:00
|
|
|
{
|
|
|
|
|
Api = api;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2020-10-27 15:47:23 +01:00
|
|
|
public EditModel<ITranslation> GetEmpty([FromServices] ITranslation blueprint) => Edit(blueprint);
|
2020-05-04 14:13:03 +02:00
|
|
|
|
|
|
|
|
|
2020-10-27 15:47:23 +01:00
|
|
|
public async Task<EditModel<ITranslation>> GetById([FromQuery] string id) => Edit(await Api.GetById(id));
|
2020-05-04 14:13:03 +02:00
|
|
|
|
|
|
|
|
|
2020-10-27 15:47:23 +01:00
|
|
|
public async Task<ListResult<ITranslation>> GetAll([FromQuery] ListQuery<ITranslation> query) => await Api.GetByQuery(query);
|
2020-05-04 14:13:03 +02:00
|
|
|
|
|
|
|
|
|
2020-08-11 16:01:10 +02:00
|
|
|
[ZeroAuthorize(Permissions.Settings.Translations, PermissionsValue.Update)]
|
2020-10-27 15:47:23 +01:00
|
|
|
public async Task<EntityResult<ITranslation>> Save([FromBody] ITranslation model) => await Api.Save(model);
|
2020-05-04 14:13:03 +02:00
|
|
|
|
|
|
|
|
|
2020-08-11 16:01:10 +02:00
|
|
|
[ZeroAuthorize(Permissions.Settings.Translations, PermissionsValue.Update)]
|
2020-10-27 15:47:23 +01:00
|
|
|
public async Task<EntityResult<ITranslation>> Delete([FromQuery] string id) => await Api.Delete(id);
|
2020-05-04 14:13:03 +02:00
|
|
|
}
|
|
|
|
|
}
|