diff --git a/RMuseum/Controllers/GanjoorController.cs b/RMuseum/Controllers/GanjoorController.cs
index 569c778b..d39f82f6 100644
--- a/RMuseum/Controllers/GanjoorController.cs
+++ b/RMuseum/Controllers/GanjoorController.cs
@@ -89,18 +89,22 @@ namespace RMuseum.Controllers
///
/// not implemented yet
/// not implemented yet
+ ///
///
[HttpGet]
[Route("poem/{id}")]
[AllowAnonymous]
[ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(GanjoorPoemCompleteViewModel))]
[ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))]
- public async Task GetPoemById(int id, bool catInfo = true, bool rhymes = true, bool recitations = true, bool images = true, bool songs = true, bool comments = true)
+ [ProducesResponseType((int)HttpStatusCode.NotFound)]
+ public async Task GetPoemById(int id, bool catInfo = true, bool rhymes = true, bool recitations = true, bool images = true, bool songs = true, bool comments = true, bool verseDetails = true)
{
RServiceResult res =
- await _ganjoorService.GetPoemById(id, catInfo, rhymes, recitations, images, songs, comments);
+ await _ganjoorService.GetPoemById(id, catInfo, rhymes, recitations, images, songs, comments, verseDetails);
if (!string.IsNullOrEmpty(res.ExceptionString))
return BadRequest(res.ExceptionString);
+ if (res.Result == null)
+ return NotFound();
return Ok(res.Result);
}
diff --git a/RMuseum/Models/Ganjoor/ViewModels/GanjoorPoemCompleteViewModel.cs b/RMuseum/Models/Ganjoor/ViewModels/GanjoorPoemCompleteViewModel.cs
index 800e4fd0..6f576437 100644
--- a/RMuseum/Models/Ganjoor/ViewModels/GanjoorPoemCompleteViewModel.cs
+++ b/RMuseum/Models/Ganjoor/ViewModels/GanjoorPoemCompleteViewModel.cs
@@ -48,6 +48,11 @@ namespace RMuseum.Models.Ganjoor.ViewModels
///
public GanjoorPoetCompleteViewModel Category { get; set; }
+ ///
+ /// verses
+ ///
+ public GanjoorVerseViewModel[] Verses { get; set; }
+
///
/// Recitations
///
diff --git a/RMuseum/Models/Ganjoor/ViewModels/GanjoorVerseViewModel.cs b/RMuseum/Models/Ganjoor/ViewModels/GanjoorVerseViewModel.cs
new file mode 100644
index 00000000..a770c1b4
--- /dev/null
+++ b/RMuseum/Models/Ganjoor/ViewModels/GanjoorVerseViewModel.cs
@@ -0,0 +1,29 @@
+namespace RMuseum.Models.Ganjoor.ViewModels
+{
+ ///
+ /// Ganjoor Verse View Model
+ ///
+ public class GanjoorVerseViewModel
+ {
+ ///
+ /// global id, auto generated (missing in Ganjoor Desktop database)
+ ///
+ public int Id { get; set; }
+
+
+ ///
+ /// vorder
+ ///
+ public int VOrder { get; set; }
+
+ ///
+ /// position
+ ///
+ public VersePosition VersePosition { get; set; }
+
+ ///
+ /// text
+ ///
+ public string Text { get; set; }
+ }
+}
diff --git a/RMuseum/RMuseum.xml b/RMuseum/RMuseum.xml
index c7124d5f..a315d65e 100644
--- a/RMuseum/RMuseum.xml
+++ b/RMuseum/RMuseum.xml
@@ -636,7 +636,7 @@
-
+
get poem by id
@@ -647,6 +647,7 @@
not implemented yet
not implemented yet
+
@@ -3516,6 +3517,11 @@
category
+
+
+ verses
+
+
Recitations
@@ -3591,6 +3597,31 @@
urlslug
+
+
+ Ganjoor Verse View Model
+
+
+
+
+ global id, auto generated (missing in Ganjoor Desktop database)
+
+
+
+
+ vorder
+
+
+
+
+ position
+
+
+
+
+ text
+
+
Import Job
@@ -4618,7 +4649,7 @@
-
+
Get Poem By Id
@@ -4629,6 +4660,7 @@
+
@@ -5399,7 +5431,7 @@
-
+
Get Poem By Id
@@ -5410,6 +5442,7 @@
+
diff --git a/RMuseum/Services/IGanjoorService.cs b/RMuseum/Services/IGanjoorService.cs
index eca9d136..8e026662 100644
--- a/RMuseum/Services/IGanjoorService.cs
+++ b/RMuseum/Services/IGanjoorService.cs
@@ -44,8 +44,9 @@ namespace RMuseum.Services
///
///
///
+ ///
///
- Task> GetPoemById(int id, bool catInfo = true, bool rhymes = true, bool recitations = true, bool images = true, bool songs = true, bool comments = true);
+ Task> GetPoemById(int id, bool catInfo = true, bool rhymes = true, bool recitations = true, bool images = true, bool songs = true, bool comments = true, bool verseDetails = true);
///
/// get poem recitations (PlainText/HtmlText are intentionally empty)
diff --git a/RMuseum/Services/Implementation/GanjoorService.cs b/RMuseum/Services/Implementation/GanjoorService.cs
index 75117d90..88d53c9f 100644
--- a/RMuseum/Services/Implementation/GanjoorService.cs
+++ b/RMuseum/Services/Implementation/GanjoorService.cs
@@ -276,8 +276,9 @@ namespace RMuseum.Services.Implementation
///
///
///
+ ///
///
- public async Task> GetPoemById(int id, bool catInfo = true, bool rhymes = true, bool recitations = true, bool images = true, bool songs = true, bool comments = true)
+ public async Task> GetPoemById(int id, bool catInfo = true, bool rhymes = true, bool recitations = true, bool images = true, bool songs = true, bool comments = true, bool verseDetails = true)
{
try
{
@@ -313,6 +314,20 @@ namespace RMuseum.Services.Implementation
imgs = imgsRes.Result;
}
+ GanjoorVerseViewModel[] verses = null;
+ if(verseDetails)
+ {
+ verses = await _context.GanjoorVerses
+ .Where(v => v.PoemId == id)
+ .OrderBy(v => v.VOrder)
+ .Select
+ (
+ v => new GanjoorVerseViewModel()
+ {
+ Id = v.Id
+ }
+ ).ToArrayAsync();
+ };
return new RServiceResult
@@ -328,7 +343,8 @@ namespace RMuseum.Services.Implementation
PlainText = poem.PlainText,
Category = cat,
Recitations = rc,
- Images = imgs
+ Images = imgs,
+ Verses = verses
}
);
}
@@ -359,7 +375,7 @@ namespace RMuseum.Services.Implementation
break;
}
- return await GetPoemById(poemId, false, false, true, false, false, false);
+ return await GetPoemById(poemId, false, false, true, false, false, false, false);
}
catch (Exception exp)
{