#393 api for removing redundant variables and simplify api calls
This commit is contained in:
parent
c7700f6491
commit
d797aead0a
@ -1080,6 +1080,23 @@ namespace RMuseum.Controllers
|
||||
return Ok(res.Result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// check if a category has any recitations
|
||||
/// </summary>
|
||||
/// <param name="catId"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("catany/{catId}")]
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(bool))]
|
||||
[ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))]
|
||||
public async Task<IActionResult> GetPoemCategoryHasAnyRecitations(int catId)
|
||||
{
|
||||
var res = await _audioService.GetPoemCategoryHasAnyRecitations(catId);
|
||||
if (!string.IsNullOrEmpty(res.ExceptionString))
|
||||
return BadRequest(res.ExceptionString);
|
||||
return Ok(res.Result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// rss for category top one recitations
|
||||
/// </summary>
|
||||
|
||||
@ -2627,6 +2627,13 @@
|
||||
<param name="includePoemText"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Controllers.RecitationController.GetPoemCategoryHasAnyRecitations(System.Int32)">
|
||||
<summary>
|
||||
check if a category has any recitations
|
||||
</summary>
|
||||
<param name="catId"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Controllers.RecitationController.GetPoemCategoryTopRecitationsRSS(System.Int32,System.Boolean)">
|
||||
<summary>
|
||||
rss for category top one recitations
|
||||
@ -17176,6 +17183,13 @@
|
||||
<param name="includePoemText"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.Implementationa.RecitationService.GetPoemCategoryHasAnyRecitations(System.Int32)">
|
||||
<summary>
|
||||
check if a category has any recitations
|
||||
</summary>
|
||||
<param name="catId"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.Implementationa.RecitationService.GetPublishedRecitationById(System.Int32)">
|
||||
<summary>
|
||||
get published recitation by id
|
||||
@ -17692,6 +17706,13 @@
|
||||
<param name="includePoemText"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.IRecitationService.GetPoemCategoryHasAnyRecitations(System.Int32)">
|
||||
<summary>
|
||||
check if a category has any recitations
|
||||
</summary>
|
||||
<param name="catId"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.IRecitationService.GetPublishedRecitationById(System.Int32)">
|
||||
<summary>
|
||||
get published recitation by id
|
||||
|
||||
@ -43,6 +43,13 @@ namespace RMuseum.Services
|
||||
/// <returns></returns>
|
||||
Task<RServiceResult<PublicRecitationViewModel[]>> GetPoemCategoryTopRecitations(int catId, bool includePoemText);
|
||||
|
||||
/// <summary>
|
||||
/// check if a category has any recitations
|
||||
/// </summary>
|
||||
/// <param name="catId"></param>
|
||||
/// <returns></returns>
|
||||
Task<RServiceResult<bool>> GetPoemCategoryHasAnyRecitations(int catId);
|
||||
|
||||
/// <summary>
|
||||
/// get published recitation by id
|
||||
/// </summary>
|
||||
|
||||
@ -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<PublicRecitationViewModel[]>(await source.ToArrayAsync());
|
||||
}
|
||||
@ -326,6 +326,30 @@ namespace RMuseum.Services.Implementationa
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// check if a category has any recitations
|
||||
/// </summary>
|
||||
/// <param name="catId"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<RServiceResult<bool>> GetPoemCategoryHasAnyRecitations(int catId)
|
||||
{
|
||||
try
|
||||
{
|
||||
return new RServiceResult<bool>(
|
||||
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<bool>(false, exp.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// get published recitation by id
|
||||
@ -449,7 +473,7 @@ namespace RMuseum.Services.Implementationa
|
||||
return new RServiceResult<bool>(true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets Verse Sync Range Information
|
||||
/// </summary>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user