diff --git a/RMuseum/Controllers/GanjoorController.cs b/RMuseum/Controllers/GanjoorController.cs
index ff3609ee..51093c00 100644
--- a/RMuseum/Controllers/GanjoorController.cs
+++ b/RMuseum/Controllers/GanjoorController.cs
@@ -854,6 +854,26 @@ namespace RMuseum.Controllers
return Ok(res.Result);//might be null
}
+ ///
+ /// get next unreviewed correction
+ ///
+ ///
+ ///
+ [HttpGet]
+ [Route("poem/correction/next")]
+ [Authorize(Policy = RMuseumSecurableItem.GanjoorEntityShortName + ":" + SecurableItem.ModifyOperationShortName)]
+ [ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(GanjoorPoemCorrectionViewModel))]
+ [ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))]
+ [ProducesResponseType((int)HttpStatusCode.NotFound)]
+ public async Task GetNextUnreviewedCorrection(int skip = 0)
+ {
+ RServiceResult res =
+ await _ganjoorService.GetNextUnreviewedCorrection(skip);
+ if (!string.IsNullOrEmpty(res.ExceptionString))
+ return BadRequest(res.ExceptionString);
+ return Ok(res.Result);//might be null
+ }
+
///
/// suggest song for poem
///
diff --git a/RMuseum/Services/IGanjoorService.cs b/RMuseum/Services/IGanjoorService.cs
index 868018b9..69bcd876 100644
--- a/RMuseum/Services/IGanjoorService.cs
+++ b/RMuseum/Services/IGanjoorService.cs
@@ -160,6 +160,13 @@ namespace RMuseum.Services
///
Task> DeletePoemCorrections(Guid userId, int poemId);
+ ///
+ /// get next unreviewed correction
+ ///
+ ///
+ ///
+ Task> GetNextUnreviewedCorrection(int skip);
+
///
/// next unreviewed track
///
diff --git a/RMuseum/Services/Implementation/GanjoorService.cs b/RMuseum/Services/Implementation/GanjoorService.cs
index 0386c056..32ae0a8b 100644
--- a/RMuseum/Services/Implementation/GanjoorService.cs
+++ b/RMuseum/Services/Implementation/GanjoorService.cs
@@ -1376,7 +1376,7 @@ namespace RMuseum.Services.Implementation
///
public async Task> GetLastUnreviewedUserCorrectionForPoem(Guid userId, int poemId)
{
- var dbCorrection = await _context.GanjoorPoemCorrections.AsNoTracking().Include(c => c.VerseOrderText)
+ var dbCorrection = await _context.GanjoorPoemCorrections.AsNoTracking().Include(c => c.VerseOrderText).Include(c => c.User)
.Where(c => c.UserId == userId && c.PoemId == poemId && c.Result == CorrectionReviewResult.NotReviewed)
.OrderByDescending(c => c.Id)
.FirstOrDefaultAsync();
@@ -1398,7 +1398,44 @@ namespace RMuseum.Services.Implementation
Note = dbCorrection.Note,
Date = dbCorrection.Date,
Reviewed = dbCorrection.Reviewed,
- Result = dbCorrection.Result
+ Result = dbCorrection.Result,
+ UserNickname = string.IsNullOrEmpty(dbCorrection.User.NickName) ? dbCorrection.User.Id.ToString() : dbCorrection.User.NickName
+ }
+ );
+ }
+
+ ///
+ /// get next unreviewed correction
+ ///
+ ///
+ ///
+ public async Task> GetNextUnreviewedCorrection(int skip)
+ {
+ var dbCorrection = await _context.GanjoorPoemCorrections.AsNoTracking().Include(c => c.VerseOrderText)
+ .Where(c => c.Result == CorrectionReviewResult.NotReviewed)
+ .OrderBy(c => c.Id)
+ .Skip(skip)
+ .FirstOrDefaultAsync();
+
+ if (dbCorrection == null)
+ return new RServiceResult(null);
+
+ return new RServiceResult
+ (
+ new GanjoorPoemCorrectionViewModel()
+ {
+ PoemId = dbCorrection.PoemId,
+ UserId = dbCorrection.UserId,
+ VerseOrderText = dbCorrection.VerseOrderText == null ? null : dbCorrection.VerseOrderText.ToArray(),
+ Title = dbCorrection.Title,
+ OriginalTitle = dbCorrection.OriginalTitle,
+ Rhythm = dbCorrection.Rhythm,
+ OriginalRhythm = dbCorrection.OriginalRhythm,
+ Note = dbCorrection.Note,
+ Date = dbCorrection.Date,
+ Reviewed = dbCorrection.Reviewed,
+ Result = dbCorrection.Result,
+ UserNickname = string.IsNullOrEmpty(dbCorrection.User.NickName) ? dbCorrection.User.Id.ToString() : dbCorrection.User.NickName
}
);
}