diff --git a/RMuseum/Controllers/RecitationController.cs b/RMuseum/Controllers/RecitationController.cs
index f275a0fe..4995af59 100644
--- a/RMuseum/Controllers/RecitationController.cs
+++ b/RMuseum/Controllers/RecitationController.cs
@@ -23,6 +23,28 @@ namespace RMuseum.Controllers
[Route("api/audio")]
public class RecitationController : Controller
{
+ ///
+ /// returns paginated published recitations, ordered by publish date descending
+ ///
+ ///
+ ///
+ ///
+ [HttpGet("published")]
+ [AllowAnonymous]
+ [ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(IEnumerable))]
+ [ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))]
+ public async Task GetPublished([FromQuery] PagingParameterModel paging, string searchTerm = "")
+ {
+
+ var res = await _audioService.GetPublishedRecitations(paging, searchTerm);
+ if (!string.IsNullOrEmpty(res.ExceptionString))
+ return BadRequest(res.ExceptionString);
+
+ // Paging Header
+ HttpContext.Response.Headers.Add("paging-headers", JsonConvert.SerializeObject(res.Result.PagingMeta));
+
+ return Ok(res.Result.Items);
+ }
///
/// Gets audio narrations, user must have recitation::moderate permission to be able to see all users narrations
@@ -61,7 +83,7 @@ namespace RMuseum.Controllers
return StatusCode((int)HttpStatusCode.Forbidden);
}
- var res = await _audioService.GetAll(paging, allUsers ? Guid.Empty : loggedOnUserId, status, searchTerm);
+ var res = await _audioService.SecureGetAll(paging, allUsers ? Guid.Empty : loggedOnUserId, status, searchTerm);
if(!string.IsNullOrEmpty(res.ExceptionString))
return BadRequest(res.ExceptionString);
@@ -152,7 +174,7 @@ namespace RMuseum.Controllers
///
[HttpGet("verses/{id}")]
[AllowAnonymous]
- [ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(string))]
+ [ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(RecitationVerseSync[]))]
[ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))]
public async Task GetPoemNarrationVerseSyncArray(int id)
{
diff --git a/RMuseum/Models/GanjoorAudio/ViewModels/PublicRecitationViewModel.cs b/RMuseum/Models/GanjoorAudio/ViewModels/PublicRecitationViewModel.cs
new file mode 100644
index 00000000..afcf779a
--- /dev/null
+++ b/RMuseum/Models/GanjoorAudio/ViewModels/PublicRecitationViewModel.cs
@@ -0,0 +1,91 @@
+using System;
+
+namespace RMuseum.Models.GanjoorAudio.ViewModels
+{
+ ///
+ /// Public (no user specific data) for publish recitations
+ ///
+ public class PublicRecitationViewModel
+ {
+ ///
+ /// Audio Id
+ ///
+ public int Id { get; set; }
+
+ ///
+ /// Ganjoor Post Id
+ ///
+ public int PoemId { get; set; }
+
+ ///
+ /// Poem Full Title
+ ///
+ public string PoemFullTitle { get; set; }
+
+ ///
+ /// Poem Full Url (without domain name)
+ ///
+ public string PoemFullUrl { get; set; }
+
+ //
+ /// Audio Title
+ ///
+ public string AudioTitle { get; set; }
+
+ ///
+ /// Audio Artist
+ ///
+ public string AudioArtist { get; set; }
+
+ ///
+ /// Audio Artist Url
+ ///
+ public string AudioArtistUrl { get; set; }
+
+ ///
+ /// Audio Source
+ ///
+ public string AudioSrc { get; set; }
+
+ ///
+ /// Audio Src Url
+ ///
+ public string AudioSrcUrl { get; set; }
+
+ ///
+ /// Legacy Audio Guid
+ ///
+ public Guid LegacyAudioGuid { get; set; }
+
+ ///
+ /// Audio File CheckSum
+ ///
+ public string Mp3FileCheckSum { get; set; }
+
+ ///
+ /// mp3 size in bytes
+ ///
+ public int Mp3SizeInBytes { get; set; }
+
+ ///
+ /// Publish Date
+ ///
+ public DateTime PublishDate { get; set; }
+
+ ///
+ /// File Last Updated
+ ///
+ public DateTime FileLastUpdated { get; set; }
+
+ ///
+ /// Mp3 Url
+ ///
+ public string Mp3Url { get; set; }
+
+ ///
+ /// Xml Url
+ ///
+ public string XmlText { get; set; }
+
+ }
+}
diff --git a/RMuseum/RMuseum.xml b/RMuseum/RMuseum.xml
index 9f92dae7..bd61bd43 100644
--- a/RMuseum/RMuseum.xml
+++ b/RMuseum/RMuseum.xml
@@ -719,6 +719,14 @@
+
+
+ returns paginated published recitations, ordered by publish date descending
+
+
+
+
+
Gets audio narrations, user must have recitation::moderate permission to be able to see all users narrations
@@ -2150,6 +2158,87 @@
is default
+
+
+ Public (no user specific data) for publish recitations
+
+
+
+
+ Audio Id
+
+
+
+
+ Ganjoor Post Id
+
+
+
+
+ Poem Full Title
+
+
+
+
+ Poem Full Url (without domain name)
+
+
+
+
+
+ Audio Artist
+
+
+
+
+ Audio Artist Url
+
+
+
+
+ Audio Source
+
+
+
+
+ Audio Src Url
+
+
+
+
+ Legacy Audio Guid
+
+
+
+
+ Audio File CheckSum
+
+
+
+
+ mp3 size in bytes
+
+
+
+
+ Publish Date
+
+
+
+
+ File Last Updated
+
+
+
+
+ Mp3 Url
+
+
+
+
+ Xml Url
+
+
Moderation Result
@@ -5219,7 +5308,7 @@
Audio Narration Service Implementation
-
+
returns list of narrations
@@ -5229,6 +5318,14 @@
+
+
+ returns list of publish narrations
+
+
+
+
+
return selected narration information
@@ -5521,7 +5618,7 @@
Audio Narration Service
-
+
returns list of narrations
@@ -5531,6 +5628,14 @@
+
+
+ returns list of publish narrations
+
+
+
+
+
return selected narration information
diff --git a/RMuseum/Services/IRecitationService.cs b/RMuseum/Services/IRecitationService.cs
index c6000a32..071ef578 100644
--- a/RMuseum/Services/IRecitationService.cs
+++ b/RMuseum/Services/IRecitationService.cs
@@ -22,7 +22,15 @@ namespace RMuseum.Services
///
///
///
- public Task> GetAll(PagingParameterModel paging, Guid filteredUserId, AudioReviewStatus status, string searchTerm);
+ public Task> SecureGetAll(PagingParameterModel paging, Guid filteredUserId, AudioReviewStatus status, string searchTerm);
+
+ ///
+ /// returns list of publish narrations
+ ///
+ ///
+ ///
+ ///
+ Task> GetPublishedRecitations(PagingParameterModel paging, string searchTerm);
///
/// return selected narration information
diff --git a/RMuseum/Services/Implementation/RecitationService.cs b/RMuseum/Services/Implementation/RecitationService.cs
index fe2eaa6e..58f6fcfa 100644
--- a/RMuseum/Services/Implementation/RecitationService.cs
+++ b/RMuseum/Services/Implementation/RecitationService.cs
@@ -39,7 +39,7 @@ namespace RMuseum.Services.Implementationa
///
///
///
- public async Task> GetAll(PagingParameterModel paging, Guid filteredUserId, AudioReviewStatus status, string searchTerm)
+ public async Task> SecureGetAll(PagingParameterModel paging, Guid filteredUserId, AudioReviewStatus status, string searchTerm)
{
try
{
@@ -70,6 +70,68 @@ namespace RMuseum.Services.Implementationa
}
}
+ ///
+ /// returns list of publish narrations
+ ///
+ ///
+ ///
+ ///
+ public async Task> GetPublishedRecitations(PagingParameterModel paging, string searchTerm)
+ {
+ try
+ {
+ var source =
+ from audio in _context.Recitations
+ join poem in _context.GanjoorPoems
+ on audio.GanjoorPostId equals poem.Id
+ where
+ audio.ReviewStatus == AudioReviewStatus.Approved
+ &&
+ (
+ string.IsNullOrEmpty(searchTerm) ||
+ (
+ !string.IsNullOrEmpty(searchTerm)
+ &&
+ (
+ audio.AudioArtist.Contains(searchTerm)
+ ||
+ audio.AudioTitle.Contains(searchTerm)
+ ||
+ poem.FullTitle.Contains(searchTerm)
+ ))
+ )
+ orderby audio.ReviewDate descending
+ 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}",
+ };
+
+ (PaginationMetadata PagingMeta, PublicRecitationViewModel[] Items) paginatedResult =
+ await QueryablePaginator.Paginate(source, paging);
+
+ return new RServiceResult<(PaginationMetadata PagingMeta, PublicRecitationViewModel[] Items)>(paginatedResult);
+ }
+ catch (Exception exp)
+ {
+ return new RServiceResult<(PaginationMetadata PagingMeta, PublicRecitationViewModel[] Items)>((PagingMeta: null, Items: null), exp.ToString());
+ }
+ }
+
///
/// return selected narration information
///