From e5c036e2cbd5ddcdefad8b75e62ef17757abb7a5 Mon Sep 17 00:00:00 2001 From: Hamid Reza Mohammadi Date: Sun, 21 Jul 2024 10:45:33 +0330 Subject: [PATCH] GetTajikPoetsAsync --- RMuseum/Controllers/GanjoorController.cs | 32 ++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/RMuseum/Controllers/GanjoorController.cs b/RMuseum/Controllers/GanjoorController.cs index 4edf23ef..12f41ad2 100644 --- a/RMuseum/Controllers/GanjoorController.cs +++ b/RMuseum/Controllers/GanjoorController.cs @@ -4272,6 +4272,10 @@ namespace RMuseum.Controllers } + /// + /// transilerate from farsi to tajiki + /// + /// [HttpPut("transilerate")] [Authorize(Policy = RMuseumSecurableItem.GanjoorEntityShortName + ":" + SecurableItem.ModifyOperationShortName)] [ProducesResponseType((int)HttpStatusCode.OK)] @@ -4282,6 +4286,34 @@ namespace RMuseum.Controllers return Ok(); } + /// + /// tajik poets + /// + /// + [HttpGet] + [Route("tajik/poets")] + [AllowAnonymous] + [ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(GanjoorTajikPoet[]))] + [ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))] + public async Task GetTajikPoetsAsync() + { + var cacheKey = $"ganjoor/tajik/poets"; + if (!_memoryCache.TryGetValue(cacheKey, out GanjoorTajikPoet[] poets)) + { + RServiceResult res = + await _ganjoorService.GetTajikPoetsAsync(); + if (!string.IsNullOrEmpty(res.ExceptionString)) + return BadRequest(res.ExceptionString); + + poets = res.Result; + if (AggressiveCacheEnabled) + _memoryCache.Set(cacheKey, poets); + + } + return Ok(poets); + } + + /// /// readonly mode