diff --git a/RMuseum/Controllers/RecitationController.cs b/RMuseum/Controllers/RecitationController.cs index f1c9f0fa..2acbdc51 100644 --- a/RMuseum/Controllers/RecitationController.cs +++ b/RMuseum/Controllers/RecitationController.cs @@ -936,6 +936,33 @@ namespace RMuseum.Controllers return Ok(); } + /// + /// edit approved mistake of a recitation text + /// + /// + /// + [HttpPut] + [Route("errors/report/edit")] + [Authorize(Policy = RMuseumSecurableItem.AudioRecitationEntityShortName + ":" + RMuseumSecurableItem.ModerateOperationShortName)] + [ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(int))] + [ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))] + [ProducesResponseType((int)HttpStatusCode.Forbidden)] + public async Task EditApprovedMistakeAsync([FromBody] RecitationErrorReportViewModel report) + { + if (ReadOnlyMode) + return BadRequest("سایت به دلایل فنی مثل انتقال سرور موقتاً در حالت فقط خواندنی قرار دارد. لطفاً ساعاتی دیگر مجدداً تلاش کنید."); + RServiceResult res = await _audioService.EditApprovedMistakeAsync(report.Id, report.ReasonText); + if (!string.IsNullOrEmpty(res.ExceptionString)) + { + return BadRequest(res.ExceptionString); + } + if (!res.Result) + { + return NotFound(); + } + return Ok(); + } + /// /// remove approved mistake /// diff --git a/RMuseum/RMuseum.xml b/RMuseum/RMuseum.xml index bc899fc8..50dfa80b 100644 --- a/RMuseum/RMuseum.xml +++ b/RMuseum/RMuseum.xml @@ -2742,6 +2742,13 @@ + + + edit approved mistake of a recitation text + + + + remove approved mistake @@ -19926,6 +19933,14 @@ + + + edit approved mistake text + + + + + compute poem recitations order @@ -20474,6 +20489,14 @@ + + + edit approved mistake text + + + + + compute poem recitations order diff --git a/RMuseum/Services/IRecitationService.cs b/RMuseum/Services/IRecitationService.cs index 2bc1eb45..7aed8d17 100644 --- a/RMuseum/Services/IRecitationService.cs +++ b/RMuseum/Services/IRecitationService.cs @@ -256,6 +256,14 @@ namespace RMuseum.Services /// Task> RemoveApprovedMistakeAsync(int id); + /// + /// edit approved mistake text + /// + /// + /// + /// + Task> EditApprovedMistakeAsync(int id, string reason); + /// /// compute poem recitations order /// diff --git a/RMuseum/Services/Implementation/RecitationService.cs b/RMuseum/Services/Implementation/RecitationService.cs index 1831fb27..84a3ad9b 100644 --- a/RMuseum/Services/Implementation/RecitationService.cs +++ b/RMuseum/Services/Implementation/RecitationService.cs @@ -2458,6 +2458,30 @@ namespace RMuseum.Services.Implementationa } } + /// + /// edit approved mistake text + /// + /// + /// + /// + public async Task> EditApprovedMistakeAsync(int id, string reason) + { + try + { + var mistake = await _context.RecitationApprovedMistakes.Where(m => m.Id == id).SingleAsync(); + mistake.Mistake = reason; + _context.Update(mistake); + await _context.SaveChangesAsync(); + + return new RServiceResult(true); + } + catch (Exception exp) + { + + return new RServiceResult(false, exp.ToString()); + } + } + /// /// compute poem recitations order ///