diff --git a/RMuseum/Controllers/GanjoorController.cs b/RMuseum/Controllers/GanjoorController.cs index 7ada6dfd..0aa6cac1 100644 --- a/RMuseum/Controllers/GanjoorController.cs +++ b/RMuseum/Controllers/GanjoorController.cs @@ -1008,7 +1008,6 @@ namespace RMuseum.Controllers [Authorize] [ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(IEnumerable))] [ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))] - [ProducesResponseType((int)HttpStatusCode.NotFound)] public async Task GetUserCorrections([FromQuery] PagingParameterModel paging) { Guid userId = @@ -1025,6 +1024,30 @@ namespace RMuseum.Controllers return Ok(res.Result.Items); } + /// + /// get list of all suggested corrections + /// + /// + /// + [HttpGet] + [Route("corrections/all")] + [Authorize(Policy = RMuseumSecurableItem.GanjoorEntityShortName + ":" + SecurableItem.ModifyOperationShortName)] + [ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(IEnumerable))] + [ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))] + public async Task GetAllCorrections([FromQuery] PagingParameterModel paging) + { + + var res = + await _ganjoorService.GetUserCorrections(Guid.Empty, paging); + + // Paging Header + HttpContext.Response.Headers.Add("paging-headers", JsonConvert.SerializeObject(res.Result.PagingMeta)); + + if (!string.IsNullOrEmpty(res.ExceptionString)) + return BadRequest(res.ExceptionString); + return Ok(res.Result.Items); + } + /// /// effective corrections for poem /// diff --git a/RMuseum/RMuseum.xml b/RMuseum/RMuseum.xml index e81ed4bd..8832c378 100644 --- a/RMuseum/RMuseum.xml +++ b/RMuseum/RMuseum.xml @@ -1058,6 +1058,13 @@ + + + get list of all suggested corrections + + + + effective corrections for poem @@ -10073,9 +10080,9 @@ - get user corrections + get user or all corrections - + if sent empty returns all corrections @@ -12574,9 +12581,9 @@ - get user corrections + get user or all corrections - + if sent empty returns all corrections diff --git a/RMuseum/Services/IGanjoorService.cs b/RMuseum/Services/IGanjoorService.cs index ceaffe93..4dd9411d 100644 --- a/RMuseum/Services/IGanjoorService.cs +++ b/RMuseum/Services/IGanjoorService.cs @@ -182,9 +182,9 @@ namespace RMuseum.Services Task> GetLastUnreviewedUserCorrectionForPoem(Guid userId, int poemId); /// - /// get user corrections + /// get user or all corrections /// - /// + /// if sent empty returns all corrections /// /// Task> GetUserCorrections(Guid userId, PagingParameterModel paging); diff --git a/RMuseum/Services/Implementation/GanjoorService.cs b/RMuseum/Services/Implementation/GanjoorService.cs index 3234df36..9002f898 100644 --- a/RMuseum/Services/Implementation/GanjoorService.cs +++ b/RMuseum/Services/Implementation/GanjoorService.cs @@ -1678,16 +1678,16 @@ namespace RMuseum.Services.Implementation } /// - /// get user corrections + /// get user or all corrections /// - /// + /// if sent empty returns all corrections /// /// public async Task> GetUserCorrections(Guid userId, PagingParameterModel paging) { var source = from dbCorrection in _context.GanjoorPoemCorrections.AsNoTracking().Include(c => c.VerseOrderText).Include(c => c.User) - where dbCorrection.UserId == userId + where userId == Guid.Empty || dbCorrection.UserId == userId orderby dbCorrection.Id descending select dbCorrection;