diff --git a/RMuseum/Controllers/GanjoorController.cs b/RMuseum/Controllers/GanjoorController.cs
index d68eb8bb..87d1b010 100644
--- a/RMuseum/Controllers/GanjoorController.cs
+++ b/RMuseum/Controllers/GanjoorController.cs
@@ -2750,21 +2750,29 @@ namespace RMuseum.Controllers
}
///
- /// sectionizing poems
+ /// get couplet sections
///
+ ///
+ ///
///
- [HttpPost("sections/onetime/fillcouplets")]
- [Authorize(Policy = RMuseumSecurableItem.GanjoorEntityShortName + ":" + SecurableItem.ModifyOperationShortName)]
- [ProducesResponseType((int)HttpStatusCode.OK)]
+ [HttpGet]
+ [Route("couplet/{poemId}/{coupletIndex}/sections")]
+ [AllowAnonymous]
+ [ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(IEnumerable))]
[ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))]
- public IActionResult StartFillingPoemSectionsCoupletIndex()
+ [ProducesResponseType((int)HttpStatusCode.NotFound)]
+ public async Task GetCoupletSectionsAsync(int poemId, int coupletIndex)
{
- var res = _ganjoorService.StartFillingPoemSectionsCoupletIndex();
+ var res =
+ await _ganjoorService.GetCoupletSectionsAsync(poemId, coupletIndex);
if (!string.IsNullOrEmpty(res.ExceptionString))
return BadRequest(res.ExceptionString);
- return Ok();
+ if (res.Result == null)
+ return NotFound();
+ return Ok(res.Result);
}
+
///
/// readonly mode
///
diff --git a/RMuseum/RMuseum.xml b/RMuseum/RMuseum.xml
index babc6441..a42b6591 100644
--- a/RMuseum/RMuseum.xml
+++ b/RMuseum/RMuseum.xml
@@ -13602,6 +13602,14 @@
+
+
+ get couplet sections
+
+
+
+
+
Start finding missing rhthms
diff --git a/RMuseum/Services/IGanjoorService.cs b/RMuseum/Services/IGanjoorService.cs
index b5030602..f7ee6d42 100644
--- a/RMuseum/Services/IGanjoorService.cs
+++ b/RMuseum/Services/IGanjoorService.cs
@@ -917,5 +917,13 @@ namespace RMuseum.Services
///
///
RServiceResult StartFillingPoemSectionsCoupletIndex();
+
+ ///
+ /// get couplet sections
+ ///
+ ///
+ ///
+ ///
+ Task> GetCoupletSectionsAsync(int poemId, int coupletIndex);
}
}
diff --git a/RMuseum/Services/Implementation/GanjoorService-Partials/GanjoorService-PoemSections.cs b/RMuseum/Services/Implementation/GanjoorService-Partials/GanjoorService-PoemSections.cs
index 92103ce9..1d05a867 100644
--- a/RMuseum/Services/Implementation/GanjoorService-Partials/GanjoorService-PoemSections.cs
+++ b/RMuseum/Services/Implementation/GanjoorService-Partials/GanjoorService-PoemSections.cs
@@ -39,7 +39,7 @@ namespace RMuseum.Services.Implementation
{
var sections = await context.GanjoorPoemSections.OrderBy(s => s.SectionType).ToListAsync();
int count = sections.Count;
-
+
for (int i = 0; i < count; i++)
{
var section = sections[i];
@@ -215,7 +215,7 @@ namespace RMuseum.Services.Implementation
if (nonCommentVerses[vIndex].VersePosition != VersePosition.Paragraph)
{
- if(jobProgressServiceEF != null)
+ if (jobProgressServiceEF != null)
{
await jobProgressServiceEF.UpdateJob(job.Id, 100, "", false, $"Poem: {poem.Id}, nonCommentVerses[{vIndex}].VersePosition != VersePosition.Paragraph");
}
@@ -463,7 +463,7 @@ namespace RMuseum.Services.Implementation
rightVerse.SectionIndex2 = verseSection.Index;
leftVerse.SectionIndex2 = verseSection.Index;
- var rl = new List();rl.Add(rightVerse);rl.Add(leftVerse);
+ var rl = new List(); rl.Add(rightVerse); rl.Add(leftVerse);
verseSection.HtmlText = PrepareHtmlText(rl);
verseSection.PlainText = PreparePlainText(rl);
@@ -480,7 +480,7 @@ namespace RMuseum.Services.Implementation
List sectionVerses = new List();
foreach (GanjoorVerse verse in verses)
{
- switch(section.VerseType)
+ switch (section.VerseType)
{
case VersePoemSectionType.First:
if (verse.SectionIndex1 == section.Index)
@@ -502,5 +502,44 @@ namespace RMuseum.Services.Implementation
}
return sectionVerses;
}
+
+ ///
+ /// get couplet sections
+ ///
+ ///
+ ///
+ ///
+ public async Task> GetCoupletSectionsAsync(int poemId, int coupletIndex)
+ {
+ var firstVerse = await _context.GanjoorVerses.AsNoTracking().Where(v => v.PoemId == poemId && v.CoupletIndex == coupletIndex).OrderBy(v => v.VOrder).SingleOrDefaultAsync();
+ if (firstVerse == null)
+ return new RServiceResult(null);//not found
+ try
+ {
+ return new RServiceResult
+ (
+ await _context.GanjoorPoemSections
+ .Where(s =>
+ s.PoemId == poemId
+ &&
+ (
+ s.Index == firstVerse.SectionIndex1
+ ||
+ s.Index == firstVerse.SectionIndex2
+ ||
+ s.Index == firstVerse.SectionIndex3
+ ||
+ s.Index == firstVerse.SectionIndex4
+ )
+ )
+ .OrderBy(s => s.SectionType)
+ .ToArrayAsync()
+ );
+ }
+ catch (Exception exp)
+ {
+ return new RServiceResult(null, exp.ToString());
+ }
+ }
}
}
\ No newline at end of file