#203 adding TranslationController
This commit is contained in:
parent
58734cfd91
commit
94d7dc17e9
44
RMuseum/Controllers/TranslationController.cs
Normal file
44
RMuseum/Controllers/TranslationController.cs
Normal file
@ -0,0 +1,44 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using RMuseum.Models.Auth.Memory;
|
||||
using RMuseum.Models.Ganjoor;
|
||||
using RMuseum.Services;
|
||||
using System;
|
||||
using System.Net;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace RMuseum.Controllers
|
||||
{
|
||||
[Produces("application/json")]
|
||||
[Route("api/translations")]
|
||||
public class TranslationController : Controller
|
||||
{
|
||||
/// <summary>
|
||||
/// add new langauge
|
||||
/// </summary>
|
||||
/// <param name="lang"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Authorize(Policy = RMuseumSecurableItem.GanjoorEntityShortName + ":" + RMuseumSecurableItem.Translations)]
|
||||
[ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(GanjoorLanguage))]
|
||||
[ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))]
|
||||
[ProducesResponseType((int)HttpStatusCode.Unauthorized)]
|
||||
public async Task<IActionResult> AddLanguageAsync([FromBody] GanjoorLanguage lang)
|
||||
{
|
||||
var res = await _translationService.AddLanguageAsync(lang.Name, lang.RightToLeft);
|
||||
if (!string.IsNullOrEmpty(res.ExceptionString))
|
||||
return BadRequest(res.ExceptionString);
|
||||
return Ok(res.Result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// translation service
|
||||
/// </summary>
|
||||
private readonly IGanjoorTranslationService _translationService;
|
||||
|
||||
public TranslationController(IGanjoorTranslationService translationService)
|
||||
{
|
||||
_translationService = translationService;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -93,6 +93,10 @@ namespace RMuseum.Models.Auth.Memory
|
||||
/// </summary>
|
||||
public const string Donations = "donations";
|
||||
|
||||
/// <summary>
|
||||
/// translations
|
||||
/// </summary>
|
||||
public const string Translations = "translations";
|
||||
|
||||
/// <summary>
|
||||
/// list of forms and their permissions
|
||||
@ -167,6 +171,7 @@ namespace RMuseum.Models.Auth.Memory
|
||||
new SecurableItemOperation(ModifyOperationShortName, "ویرایش محتوا", false),
|
||||
new SecurableItemOperation(Banners, "مدیریت آگاهیها", false),
|
||||
new SecurableItemOperation(Donations, "مدیریت کمکهای مالی", false),
|
||||
new SecurableItemOperation(Translations, "ترجمه", false),
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@ -1634,6 +1634,18 @@
|
||||
</summary>
|
||||
<param name="bannersService"></param>
|
||||
</member>
|
||||
<member name="M:RMuseum.Controllers.TranslationController.AddLanguageAsync(RMuseum.Models.Ganjoor.GanjoorLanguage)">
|
||||
<summary>
|
||||
add new langauge
|
||||
</summary>
|
||||
<param name="lang"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="F:RMuseum.Controllers.TranslationController._translationService">
|
||||
<summary>
|
||||
translation service
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:RMuseum.DbContext.RMuseumDbContext">
|
||||
<summary>
|
||||
Museum Database Context
|
||||
@ -2803,6 +2815,11 @@
|
||||
donations
|
||||
</summary>
|
||||
</member>
|
||||
<member name="F:RMuseum.Models.Auth.Memory.RMuseumSecurableItem.Translations">
|
||||
<summary>
|
||||
translations
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:RMuseum.Models.Auth.Memory.RMuseumSecurableItem.Items">
|
||||
<summary>
|
||||
list of forms and their permissions
|
||||
|
||||
Loading…
Reference in New Issue
Block a user