2020-05-04 14:13:03 +02:00
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using zero.Core.Api;
|
|
|
|
|
using zero.Core.Entities;
|
2020-08-27 16:12:47 +02:00
|
|
|
using zero.Core.Extensions;
|
2020-05-04 14:13:03 +02:00
|
|
|
using zero.Core.Identity;
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
ITranslation Blueprint;
|
2020-05-04 14:13:03 +02:00
|
|
|
|
2020-08-27 16:12:47 +02:00
|
|
|
public TranslationsController(ITranslationsApi api, ITranslation blueprint)
|
2020-05-04 14:13:03 +02:00
|
|
|
{
|
|
|
|
|
Api = api;
|
2020-08-27 16:12:47 +02:00
|
|
|
Blueprint = blueprint;
|
2020-05-04 14:13:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Get translation by id
|
|
|
|
|
/// </summary>
|
2020-08-27 16:12:47 +02:00
|
|
|
public IActionResult GetEmpty() => Edit(Blueprint.Clone());
|
2020-05-04 14:13:03 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Get translation by id
|
|
|
|
|
/// </summary>
|
2020-06-03 12:57:29 +02:00
|
|
|
public async Task<IActionResult> GetById([FromQuery] string id) => Edit(await Api.GetById(id));
|
2020-05-04 14:13:03 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Get all translations
|
|
|
|
|
/// </summary>
|
2020-08-27 16:12:47 +02:00
|
|
|
public async Task<IActionResult> GetAll([FromQuery] ListQuery<ITranslation> query) => Json(await Api.GetByQuery(query));
|
2020-05-04 14:13:03 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Save translation
|
|
|
|
|
/// </summary>
|
2020-08-11 16:01:10 +02:00
|
|
|
[ZeroAuthorize(Permissions.Settings.Translations, PermissionsValue.Update)]
|
2020-08-27 16:12:47 +02:00
|
|
|
public async Task<IActionResult> Save([FromBody] ITranslation model) => Json(await Api.Save(model));
|
2020-05-04 14:13:03 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Deletes a translation
|
|
|
|
|
/// </summary>
|
2020-08-11 16:01:10 +02:00
|
|
|
[ZeroAuthorize(Permissions.Settings.Translations, PermissionsValue.Update)]
|
2020-05-24 18:40:30 +02:00
|
|
|
public async Task<IActionResult> Delete([FromQuery] string id) => Json(await Api.Delete(id));
|
2020-05-04 14:13:03 +02:00
|
|
|
}
|
|
|
|
|
}
|