#47 poem recitations
This commit is contained in:
parent
4352f3755c
commit
b949f49f5a
@ -2,6 +2,7 @@
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using RMuseum.Models.Auth.Memory;
|
using RMuseum.Models.Auth.Memory;
|
||||||
using RMuseum.Models.Ganjoor;
|
using RMuseum.Models.Ganjoor;
|
||||||
|
using RMuseum.Models.GanjoorAudio.ViewModels;
|
||||||
using RMuseum.Services;
|
using RMuseum.Services;
|
||||||
using RSecurityBackend.Models.Generic;
|
using RSecurityBackend.Models.Generic;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
@ -32,6 +33,25 @@ namespace RMuseum.Controllers
|
|||||||
return Ok(res.Result);
|
return Ok(res.Result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// get poem recitations (PlainText/HtmlText are intentionally empty)
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet]
|
||||||
|
[Route("poem/{id}/recitations")]
|
||||||
|
[AllowAnonymous]
|
||||||
|
[ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(PublicRecitationViewModel[]))]
|
||||||
|
[ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))]
|
||||||
|
public async Task<IActionResult> GetPoemRecitations(int id)
|
||||||
|
{
|
||||||
|
RServiceResult<PublicRecitationViewModel[]> res =
|
||||||
|
await _ganjoorService.GetPoemRecitations(id);
|
||||||
|
if (!string.IsNullOrEmpty(res.ExceptionString))
|
||||||
|
return BadRequest(res.ExceptionString);
|
||||||
|
return Ok(res.Result);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// imports data from ganjoor SQLite database
|
/// imports data from ganjoor SQLite database
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@ -622,6 +622,13 @@
|
|||||||
<param name="id"></param>
|
<param name="id"></param>
|
||||||
<returns></returns>
|
<returns></returns>
|
||||||
</member>
|
</member>
|
||||||
|
<member name="M:RMuseum.Controllers.GanjoorController.GetPoemRecitations(System.Int32)">
|
||||||
|
<summary>
|
||||||
|
get poem recitations (PlainText/HtmlText are intentionally empty)
|
||||||
|
</summary>
|
||||||
|
<param name="id"></param>
|
||||||
|
<returns></returns>
|
||||||
|
</member>
|
||||||
<member name="M:RMuseum.Controllers.GanjoorController.ImportLocalSQLiteDb">
|
<member name="M:RMuseum.Controllers.GanjoorController.ImportLocalSQLiteDb">
|
||||||
<summary>
|
<summary>
|
||||||
imports data from ganjoor SQLite database
|
imports data from ganjoor SQLite database
|
||||||
@ -4388,6 +4395,13 @@
|
|||||||
<param name="id"></param>
|
<param name="id"></param>
|
||||||
<returns></returns>
|
<returns></returns>
|
||||||
</member>
|
</member>
|
||||||
|
<member name="M:RMuseum.Services.IGanjoorService.GetPoemRecitations(System.Int32)">
|
||||||
|
<summary>
|
||||||
|
get poem recitations (PlainText/HtmlText are intentionally empty)
|
||||||
|
</summary>
|
||||||
|
<param name="id"></param>
|
||||||
|
<returns></returns>
|
||||||
|
</member>
|
||||||
<member name="M:RMuseum.Services.IGanjoorService.ImportLocalSQLiteDb">
|
<member name="M:RMuseum.Services.IGanjoorService.ImportLocalSQLiteDb">
|
||||||
<summary>
|
<summary>
|
||||||
imports unimported poem data from a locally accessible ganjoor SqlLite database
|
imports unimported poem data from a locally accessible ganjoor SqlLite database
|
||||||
@ -5106,6 +5120,13 @@
|
|||||||
<param name="id"></param>
|
<param name="id"></param>
|
||||||
<returns></returns>
|
<returns></returns>
|
||||||
</member>
|
</member>
|
||||||
|
<member name="M:RMuseum.Services.Implementation.GanjoorService.GetPoemRecitations(System.Int32)">
|
||||||
|
<summary>
|
||||||
|
get poem recitations (PlainText/HtmlText are intentionally empty)
|
||||||
|
</summary>
|
||||||
|
<param name="id"></param>
|
||||||
|
<returns></returns>
|
||||||
|
</member>
|
||||||
<member name="M:RMuseum.Services.Implementation.GanjoorService.ImportLocalSQLiteDb">
|
<member name="M:RMuseum.Services.Implementation.GanjoorService.ImportLocalSQLiteDb">
|
||||||
<summary>
|
<summary>
|
||||||
imports unimported poem data from a locally accessible ganjoor SqlLite database
|
imports unimported poem data from a locally accessible ganjoor SqlLite database
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
using RMuseum.Models.Ganjoor;
|
using RMuseum.Models.Ganjoor;
|
||||||
|
using RMuseum.Models.GanjoorAudio.ViewModels;
|
||||||
using RSecurityBackend.Models.Generic;
|
using RSecurityBackend.Models.Generic;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
@ -16,6 +17,13 @@ namespace RMuseum.Services
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<RServiceResult<GanjoorPoem>> GetPoemById(int id);
|
Task<RServiceResult<GanjoorPoem>> GetPoemById(int id);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// get poem recitations (PlainText/HtmlText are intentionally empty)
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<RServiceResult<PublicRecitationViewModel[]>> GetPoemRecitations(int id);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// imports unimported poem data from a locally accessible ganjoor SqlLite database
|
/// imports unimported poem data from a locally accessible ganjoor SqlLite database
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@ -4,6 +4,8 @@ using Microsoft.EntityFrameworkCore;
|
|||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using RMuseum.DbContext;
|
using RMuseum.DbContext;
|
||||||
using RMuseum.Models.Ganjoor;
|
using RMuseum.Models.Ganjoor;
|
||||||
|
using RMuseum.Models.GanjoorAudio;
|
||||||
|
using RMuseum.Models.GanjoorAudio.ViewModels;
|
||||||
using RSecurityBackend.Models.Generic;
|
using RSecurityBackend.Models.Generic;
|
||||||
using System;
|
using System;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
@ -44,6 +46,53 @@ namespace RMuseum.Services.Implementation
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// get poem recitations (PlainText/HtmlText are intentionally empty)
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<RServiceResult<PublicRecitationViewModel[]>> 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<PublicRecitationViewModel[]>(await source.ToArrayAsync());
|
||||||
|
}
|
||||||
|
catch (Exception exp)
|
||||||
|
{
|
||||||
|
return new RServiceResult<PublicRecitationViewModel[]>(null, exp.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#region Date import / modifications
|
#region Date import / modifications
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user