diff --git a/RMuseum/Controllers/GanjoorController.cs b/RMuseum/Controllers/GanjoorController.cs
index 5b98433c..a783ecc0 100644
--- a/RMuseum/Controllers/GanjoorController.cs
+++ b/RMuseum/Controllers/GanjoorController.cs
@@ -2,6 +2,7 @@
using Microsoft.AspNetCore.Mvc;
using RMuseum.Models.Auth.Memory;
using RMuseum.Models.Ganjoor;
+using RMuseum.Models.GanjoorAudio.ViewModels;
using RMuseum.Services;
using RSecurityBackend.Models.Generic;
using System.Net;
@@ -32,6 +33,25 @@ namespace RMuseum.Controllers
return Ok(res.Result);
}
+ ///
+ /// get poem recitations (PlainText/HtmlText are intentionally empty)
+ ///
+ ///
+ ///
+ [HttpGet]
+ [Route("poem/{id}/recitations")]
+ [AllowAnonymous]
+ [ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(PublicRecitationViewModel[]))]
+ [ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))]
+ public async Task GetPoemRecitations(int id)
+ {
+ RServiceResult res =
+ await _ganjoorService.GetPoemRecitations(id);
+ if (!string.IsNullOrEmpty(res.ExceptionString))
+ return BadRequest(res.ExceptionString);
+ return Ok(res.Result);
+ }
+
///
/// imports data from ganjoor SQLite database
///
diff --git a/RMuseum/RMuseum.xml b/RMuseum/RMuseum.xml
index 7a6145a8..61f1bdac 100644
--- a/RMuseum/RMuseum.xml
+++ b/RMuseum/RMuseum.xml
@@ -622,6 +622,13 @@
+
+
+ get poem recitations (PlainText/HtmlText are intentionally empty)
+
+
+
+
imports data from ganjoor SQLite database
@@ -4388,6 +4395,13 @@
+
+
+ get poem recitations (PlainText/HtmlText are intentionally empty)
+
+
+
+
imports unimported poem data from a locally accessible ganjoor SqlLite database
@@ -5106,6 +5120,13 @@
+
+
+ get poem recitations (PlainText/HtmlText are intentionally empty)
+
+
+
+
imports unimported poem data from a locally accessible ganjoor SqlLite database
diff --git a/RMuseum/Services/IGanjoorService.cs b/RMuseum/Services/IGanjoorService.cs
index da97b981..3d985c18 100644
--- a/RMuseum/Services/IGanjoorService.cs
+++ b/RMuseum/Services/IGanjoorService.cs
@@ -1,4 +1,5 @@
using RMuseum.Models.Ganjoor;
+using RMuseum.Models.GanjoorAudio.ViewModels;
using RSecurityBackend.Models.Generic;
using System.Threading.Tasks;
@@ -16,6 +17,13 @@ namespace RMuseum.Services
///
Task> GetPoemById(int id);
+ ///
+ /// get poem recitations (PlainText/HtmlText are intentionally empty)
+ ///
+ ///
+ ///
+ Task> GetPoemRecitations(int id);
+
///
/// imports unimported poem data from a locally accessible ganjoor SqlLite database
///
diff --git a/RMuseum/Services/Implementation/GanjoorService.cs b/RMuseum/Services/Implementation/GanjoorService.cs
index 4c11aba9..167e3d99 100644
--- a/RMuseum/Services/Implementation/GanjoorService.cs
+++ b/RMuseum/Services/Implementation/GanjoorService.cs
@@ -4,6 +4,8 @@ using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using RMuseum.DbContext;
using RMuseum.Models.Ganjoor;
+using RMuseum.Models.GanjoorAudio;
+using RMuseum.Models.GanjoorAudio.ViewModels;
using RSecurityBackend.Models.Generic;
using System;
using System.Data;
@@ -44,6 +46,53 @@ namespace RMuseum.Services.Implementation
}
}
+ ///
+ /// get poem recitations (PlainText/HtmlText are intentionally empty)
+ ///
+ ///
+ ///
+ public async Task> GetPoemRecitations(int id)
+ {
+ try
+ {
+ var source =
+ from audio in _context.Recitations
+ join poem in _context.GanjoorPoems
+ on audio.GanjoorPostId equals poem.Id
+ where
+ audio.ReviewStatus == AudioReviewStatus.Approved
+ &&
+ poem.Id == id
+ orderby audio.AudioOrder
+ select new PublicRecitationViewModel()
+ {
+ Id = audio.Id,
+ PoemId = audio.GanjoorPostId,
+ PoemFullTitle = poem.FullTitle,
+ PoemFullUrl = poem.FullUrl,
+ AudioTitle = audio.AudioTitle,
+ AudioArtist = audio.AudioArtist,
+ AudioArtistUrl = audio.AudioArtistUrl,
+ AudioSrc = audio.AudioSrc,
+ AudioSrcUrl = audio.AudioSrcUrl,
+ LegacyAudioGuid = audio.LegacyAudioGuid,
+ Mp3FileCheckSum = audio.Mp3FileCheckSum,
+ Mp3SizeInBytes = audio.Mp3SizeInBytes,
+ PublishDate = audio.ReviewDate,
+ FileLastUpdated = audio.FileLastUpdated,
+ Mp3Url = $"https://ganjgah.ir/api/audio/file/{audio.Id}.mp3",
+ XmlText = $"https://ganjgah.ir/api/audio/xml/{audio.Id}",
+ PlainText = "", //poem.PlainText
+ HtmlText = "",//poem.HtmlText
+ };
+ return new RServiceResult(await source.ToArrayAsync());
+ }
+ catch (Exception exp)
+ {
+ return new RServiceResult(null, exp.ToString());
+ }
+ }
+
#region Date import / modifications
///