#416 remove approved mistake api
This commit is contained in:
parent
35011c4cb6
commit
eb0612764a
@ -903,6 +903,30 @@ namespace RMuseum.Controllers
|
||||
return Ok();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// remove approved mistake
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpDelete]
|
||||
[Route("errors/approved/{id}")]
|
||||
[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<IActionResult> RemoveApprovedMistakeAsync(int id)
|
||||
{
|
||||
if (ReadOnlyMode)
|
||||
return BadRequest("سایت به دلایل فنی مثل انتقال سرور موقتاً در حالت فقط خواندنی قرار دارد. لطفاً ساعاتی دیگر مجدداً تلاش کنید.");
|
||||
RServiceResult<bool> res = await _audioService.RemoveApprovedMistakeAsync(id);
|
||||
if (!string.IsNullOrEmpty(res.ExceptionString))
|
||||
{
|
||||
return BadRequest(res.ExceptionString);
|
||||
}
|
||||
|
||||
return Ok();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// up vote a recitation
|
||||
/// </summary>
|
||||
|
||||
@ -2614,6 +2614,13 @@
|
||||
<param name="report"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Controllers.RecitationController.RemoveApprovedMistakeAsync(System.Int32)">
|
||||
<summary>
|
||||
remove approved mistake
|
||||
</summary>
|
||||
<param name="id"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Controllers.RecitationController.UpVoteRecitationAsync(System.Int32)">
|
||||
<summary>
|
||||
up vote a recitation
|
||||
@ -18928,6 +18935,13 @@
|
||||
<param name="report"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.Implementationa.RecitationService.RemoveApprovedMistakeAsync(System.Int32)">
|
||||
<summary>
|
||||
remove approved mistake
|
||||
</summary>
|
||||
<param name="id"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.Implementationa.RecitationService.ComputePoemRecitationsOrdersAsync(System.Int32,System.Boolean)">
|
||||
<summary>
|
||||
compute poem recitations order
|
||||
@ -19469,6 +19483,13 @@
|
||||
<param name="report"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.IRecitationService.RemoveApprovedMistakeAsync(System.Int32)">
|
||||
<summary>
|
||||
remove approved mistake
|
||||
</summary>
|
||||
<param name="id"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.IRecitationService.ComputePoemRecitationsOrdersAsync(System.Int32,System.Boolean)">
|
||||
<summary>
|
||||
compute poem recitations order
|
||||
|
||||
@ -249,6 +249,13 @@ namespace RMuseum.Services
|
||||
/// <returns></returns>
|
||||
Task<RServiceResult<bool>> AddReportToTheApprovedMistakesAsync(RecitationErrorReportViewModel report);
|
||||
|
||||
/// <summary>
|
||||
/// remove approved mistake
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
Task<RServiceResult<bool>> RemoveApprovedMistakeAsync(int id);
|
||||
|
||||
/// <summary>
|
||||
/// compute poem recitations order
|
||||
/// </summary>
|
||||
|
||||
@ -2430,6 +2430,32 @@ namespace RMuseum.Services.Implementationa
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// remove approved mistake
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<RServiceResult<bool>> RemoveApprovedMistakeAsync(int id)
|
||||
{
|
||||
try
|
||||
{
|
||||
var mistake = await _context.RecitationApprovedMistakes.Where(m => m.Id == id).SingleAsync();
|
||||
var recitation = await _context.Recitations.AsNoTracking().Where(r => r.Id == mistake.RecitationId).SingleAsync();
|
||||
_context.Remove(mistake);
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
|
||||
await ComputePoemRecitationsOrdersAsync(recitation.GanjoorPostId);
|
||||
|
||||
return new RServiceResult<bool>(true);
|
||||
}
|
||||
catch (Exception exp)
|
||||
{
|
||||
|
||||
return new RServiceResult<bool>(false, exp.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// compute poem recitations order
|
||||
/// </summary>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user