diff --git a/RMuseum/Controllers/RecitationController.cs b/RMuseum/Controllers/RecitationController.cs
index aac3c132..e03c570d 100644
--- a/RMuseum/Controllers/RecitationController.cs
+++ b/RMuseum/Controllers/RecitationController.cs
@@ -1080,6 +1080,23 @@ namespace RMuseum.Controllers
return Ok(res.Result);
}
+ ///
+ /// check if a category has any recitations
+ ///
+ ///
+ ///
+ [HttpGet("catany/{catId}")]
+ [AllowAnonymous]
+ [ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(bool))]
+ [ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))]
+ public async Task GetPoemCategoryHasAnyRecitations(int catId)
+ {
+ var res = await _audioService.GetPoemCategoryHasAnyRecitations(catId);
+ if (!string.IsNullOrEmpty(res.ExceptionString))
+ return BadRequest(res.ExceptionString);
+ return Ok(res.Result);
+ }
+
///
/// rss for category top one recitations
///
diff --git a/RMuseum/RMuseum.xml b/RMuseum/RMuseum.xml
index 60a98a56..14c0b0de 100644
--- a/RMuseum/RMuseum.xml
+++ b/RMuseum/RMuseum.xml
@@ -2627,6 +2627,13 @@
+
+
+ check if a category has any recitations
+
+
+
+
rss for category top one recitations
@@ -17176,6 +17183,13 @@
+
+
+ check if a category has any recitations
+
+
+
+
get published recitation by id
@@ -17692,6 +17706,13 @@
+
+
+ check if a category has any recitations
+
+
+
+
get published recitation by id
diff --git a/RMuseum/Services/IRecitationService.cs b/RMuseum/Services/IRecitationService.cs
index 4b8e4d83..9e540975 100644
--- a/RMuseum/Services/IRecitationService.cs
+++ b/RMuseum/Services/IRecitationService.cs
@@ -43,6 +43,13 @@ namespace RMuseum.Services
///
Task> GetPoemCategoryTopRecitations(int catId, bool includePoemText);
+ ///
+ /// check if a category has any recitations
+ ///
+ ///
+ ///
+ Task> GetPoemCategoryHasAnyRecitations(int catId);
+
///
/// get published recitation by id
///
diff --git a/RMuseum/Services/Implementation/RecitationService.cs b/RMuseum/Services/Implementation/RecitationService.cs
index 4b2f84f2..5a840cec 100644
--- a/RMuseum/Services/Implementation/RecitationService.cs
+++ b/RMuseum/Services/Implementation/RecitationService.cs
@@ -285,38 +285,38 @@ namespace RMuseum.Services.Implementationa
{
try
{
- var source = from poem in _context.GanjoorPoems.AsNoTracking()
- from audio in _context.Recitations
- .Where(a => a.GanjoorPostId == poem.Id && a.ReviewStatus == AudioReviewStatus.Approved)
- .OrderBy(a => a.AudioOrder)
- .Take(1)
- .DefaultIfEmpty()
- where
- poem.CatId == catId && audio != null
- orderby poem.Id
- 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 = $"{WebServiceUrl.Url}/api/audio/file/{audio.Id}.mp3",
- XmlText = $"{WebServiceUrl.Url}/api/audio/xml/{audio.Id}",
- PlainText = includePoemText ? poem.PlainText : "",
- HtmlText = includePoemText ? poem.HtmlText : "",
- AudioOrder = audio.AudioOrder,
- UpVotedByUser = false,
- };
+ var source = from poem in _context.GanjoorPoems.AsNoTracking()
+ from audio in _context.Recitations
+ .Where(a => a.GanjoorPostId == poem.Id && a.ReviewStatus == AudioReviewStatus.Approved)
+ .OrderBy(a => a.AudioOrder)
+ .Take(1)
+ .DefaultIfEmpty()
+ where
+ poem.CatId == catId && audio != null
+ orderby poem.Id
+ 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 = $"{WebServiceUrl.Url}/api/audio/file/{audio.Id}.mp3",
+ XmlText = $"{WebServiceUrl.Url}/api/audio/xml/{audio.Id}",
+ PlainText = includePoemText ? poem.PlainText : "",
+ HtmlText = includePoemText ? poem.HtmlText : "",
+ AudioOrder = audio.AudioOrder,
+ UpVotedByUser = false,
+ };
return new RServiceResult(await source.ToArrayAsync());
}
@@ -326,6 +326,30 @@ namespace RMuseum.Services.Implementationa
}
}
+ ///
+ /// check if a category has any recitations
+ ///
+ ///
+ ///
+ public async Task> GetPoemCategoryHasAnyRecitations(int catId)
+ {
+ try
+ {
+ return new RServiceResult(
+ await _context.Recitations.AsNoTracking().Where(
+ a =>
+ _context.GanjoorPoems.Where(p => p.CatId == catId && p.Id == a.GanjoorPostId
+ &&
+ a.ReviewStatus == AudioReviewStatus.Approved
+ ).Any()
+ ).AnyAsync());
+ }
+ catch (Exception exp)
+ {
+ return new RServiceResult(false, exp.ToString());
+ }
+ }
+
///
/// get published recitation by id
@@ -449,7 +473,7 @@ namespace RMuseum.Services.Implementationa
return new RServiceResult(true);
}
-
+
///
/// Gets Verse Sync Range Information
///