adding verse details to poem by id api
This commit is contained in:
parent
9fdd65be29
commit
3de332df2f
@ -89,18 +89,22 @@ namespace RMuseum.Controllers
|
||||
/// <param name="images"></param>
|
||||
/// <param name="songs">not implemented yet</param>
|
||||
/// <param name="comments">not implemented yet</param>
|
||||
/// <param name="verseDetails"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
[Route("poem/{id}")]
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(GanjoorPoemCompleteViewModel))]
|
||||
[ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))]
|
||||
public async Task<IActionResult> GetPoemById(int id, bool catInfo = true, bool rhymes = true, bool recitations = true, bool images = true, bool songs = true, bool comments = true)
|
||||
[ProducesResponseType((int)HttpStatusCode.NotFound)]
|
||||
public async Task<IActionResult> GetPoemById(int id, bool catInfo = true, bool rhymes = true, bool recitations = true, bool images = true, bool songs = true, bool comments = true, bool verseDetails = true)
|
||||
{
|
||||
RServiceResult<GanjoorPoemCompleteViewModel> res =
|
||||
await _ganjoorService.GetPoemById(id, catInfo, rhymes, recitations, images, songs, comments);
|
||||
await _ganjoorService.GetPoemById(id, catInfo, rhymes, recitations, images, songs, comments, verseDetails);
|
||||
if (!string.IsNullOrEmpty(res.ExceptionString))
|
||||
return BadRequest(res.ExceptionString);
|
||||
if (res.Result == null)
|
||||
return NotFound();
|
||||
return Ok(res.Result);
|
||||
}
|
||||
|
||||
|
||||
@ -48,6 +48,11 @@ namespace RMuseum.Models.Ganjoor.ViewModels
|
||||
/// </summary>
|
||||
public GanjoorPoetCompleteViewModel Category { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// verses
|
||||
/// </summary>
|
||||
public GanjoorVerseViewModel[] Verses { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Recitations
|
||||
/// </summary>
|
||||
|
||||
29
RMuseum/Models/Ganjoor/ViewModels/GanjoorVerseViewModel.cs
Normal file
29
RMuseum/Models/Ganjoor/ViewModels/GanjoorVerseViewModel.cs
Normal file
@ -0,0 +1,29 @@
|
||||
namespace RMuseum.Models.Ganjoor.ViewModels
|
||||
{
|
||||
/// <summary>
|
||||
/// Ganjoor Verse View Model
|
||||
/// </summary>
|
||||
public class GanjoorVerseViewModel
|
||||
{
|
||||
/// <summary>
|
||||
/// global id, auto generated (missing in Ganjoor Desktop database)
|
||||
/// </summary>
|
||||
public int Id { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// vorder
|
||||
/// </summary>
|
||||
public int VOrder { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// position
|
||||
/// </summary>
|
||||
public VersePosition VersePosition { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// text
|
||||
/// </summary>
|
||||
public string Text { get; set; }
|
||||
}
|
||||
}
|
||||
@ -636,7 +636,7 @@
|
||||
<param name="id"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Controllers.GanjoorController.GetPoemById(System.Int32,System.Boolean,System.Boolean,System.Boolean,System.Boolean,System.Boolean,System.Boolean)">
|
||||
<member name="M:RMuseum.Controllers.GanjoorController.GetPoemById(System.Int32,System.Boolean,System.Boolean,System.Boolean,System.Boolean,System.Boolean,System.Boolean,System.Boolean)">
|
||||
<summary>
|
||||
get poem by id
|
||||
</summary>
|
||||
@ -647,6 +647,7 @@
|
||||
<param name="images"></param>
|
||||
<param name="songs">not implemented yet</param>
|
||||
<param name="comments">not implemented yet</param>
|
||||
<param name="verseDetails"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Controllers.GanjoorController.GetPoemRecitations(System.Int32)">
|
||||
@ -3516,6 +3517,11 @@
|
||||
category
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:RMuseum.Models.Ganjoor.ViewModels.GanjoorPoemCompleteViewModel.Verses">
|
||||
<summary>
|
||||
verses
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:RMuseum.Models.Ganjoor.ViewModels.GanjoorPoemCompleteViewModel.Recitations">
|
||||
<summary>
|
||||
Recitations
|
||||
@ -3591,6 +3597,31 @@
|
||||
urlslug
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:RMuseum.Models.Ganjoor.ViewModels.GanjoorVerseViewModel">
|
||||
<summary>
|
||||
Ganjoor Verse View Model
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:RMuseum.Models.Ganjoor.ViewModels.GanjoorVerseViewModel.Id">
|
||||
<summary>
|
||||
global id, auto generated (missing in Ganjoor Desktop database)
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:RMuseum.Models.Ganjoor.ViewModels.GanjoorVerseViewModel.VOrder">
|
||||
<summary>
|
||||
vorder
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:RMuseum.Models.Ganjoor.ViewModels.GanjoorVerseViewModel.VersePosition">
|
||||
<summary>
|
||||
position
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:RMuseum.Models.Ganjoor.ViewModels.GanjoorVerseViewModel.Text">
|
||||
<summary>
|
||||
text
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:RMuseum.Models.ImportJob.ImportJob">
|
||||
<summary>
|
||||
Import Job
|
||||
@ -4618,7 +4649,7 @@
|
||||
<param name="id"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.IGanjoorService.GetPoemById(System.Int32,System.Boolean,System.Boolean,System.Boolean,System.Boolean,System.Boolean,System.Boolean)">
|
||||
<member name="M:RMuseum.Services.IGanjoorService.GetPoemById(System.Int32,System.Boolean,System.Boolean,System.Boolean,System.Boolean,System.Boolean,System.Boolean,System.Boolean)">
|
||||
<summary>
|
||||
Get Poem By Id
|
||||
</summary>
|
||||
@ -4629,6 +4660,7 @@
|
||||
<param name="images"></param>
|
||||
<param name="songs"></param>
|
||||
<param name="comments"></param>
|
||||
<param name="verseDetails"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.IGanjoorService.GetPoemRecitations(System.Int32)">
|
||||
@ -5399,7 +5431,7 @@
|
||||
<param name="id"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.Implementation.GanjoorService.GetPoemById(System.Int32,System.Boolean,System.Boolean,System.Boolean,System.Boolean,System.Boolean,System.Boolean)">
|
||||
<member name="M:RMuseum.Services.Implementation.GanjoorService.GetPoemById(System.Int32,System.Boolean,System.Boolean,System.Boolean,System.Boolean,System.Boolean,System.Boolean,System.Boolean)">
|
||||
<summary>
|
||||
Get Poem By Id
|
||||
</summary>
|
||||
@ -5410,6 +5442,7 @@
|
||||
<param name="images"></param>
|
||||
<param name="songs"></param>
|
||||
<param name="comments"></param>
|
||||
<param name="verseDetails"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.Implementation.GanjoorService.Faal">
|
||||
|
||||
@ -44,8 +44,9 @@ namespace RMuseum.Services
|
||||
/// <param name="images"></param>
|
||||
/// <param name="songs"></param>
|
||||
/// <param name="comments"></param>
|
||||
/// <param name="verseDetails"></param>
|
||||
/// <returns></returns>
|
||||
Task<RServiceResult<GanjoorPoemCompleteViewModel>> GetPoemById(int id, bool catInfo = true, bool rhymes = true, bool recitations = true, bool images = true, bool songs = true, bool comments = true);
|
||||
Task<RServiceResult<GanjoorPoemCompleteViewModel>> GetPoemById(int id, bool catInfo = true, bool rhymes = true, bool recitations = true, bool images = true, bool songs = true, bool comments = true, bool verseDetails = true);
|
||||
|
||||
/// <summary>
|
||||
/// get poem recitations (PlainText/HtmlText are intentionally empty)
|
||||
|
||||
@ -276,8 +276,9 @@ namespace RMuseum.Services.Implementation
|
||||
/// <param name="images"></param>
|
||||
/// <param name="songs"></param>
|
||||
/// <param name="comments"></param>
|
||||
/// <param name="verseDetails"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<RServiceResult<GanjoorPoemCompleteViewModel>> GetPoemById(int id, bool catInfo = true, bool rhymes = true, bool recitations = true, bool images = true, bool songs = true, bool comments = true)
|
||||
public async Task<RServiceResult<GanjoorPoemCompleteViewModel>> GetPoemById(int id, bool catInfo = true, bool rhymes = true, bool recitations = true, bool images = true, bool songs = true, bool comments = true, bool verseDetails = true)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -313,6 +314,20 @@ namespace RMuseum.Services.Implementation
|
||||
imgs = imgsRes.Result;
|
||||
}
|
||||
|
||||
GanjoorVerseViewModel[] verses = null;
|
||||
if(verseDetails)
|
||||
{
|
||||
verses = await _context.GanjoorVerses
|
||||
.Where(v => v.PoemId == id)
|
||||
.OrderBy(v => v.VOrder)
|
||||
.Select
|
||||
(
|
||||
v => new GanjoorVerseViewModel()
|
||||
{
|
||||
Id = v.Id
|
||||
}
|
||||
).ToArrayAsync();
|
||||
};
|
||||
|
||||
|
||||
return new RServiceResult<GanjoorPoemCompleteViewModel>
|
||||
@ -328,7 +343,8 @@ namespace RMuseum.Services.Implementation
|
||||
PlainText = poem.PlainText,
|
||||
Category = cat,
|
||||
Recitations = rc,
|
||||
Images = imgs
|
||||
Images = imgs,
|
||||
Verses = verses
|
||||
}
|
||||
);
|
||||
}
|
||||
@ -359,7 +375,7 @@ namespace RMuseum.Services.Implementation
|
||||
break;
|
||||
}
|
||||
|
||||
return await GetPoemById(poemId, false, false, true, false, false, false);
|
||||
return await GetPoemById(poemId, false, false, true, false, false, false, false);
|
||||
}
|
||||
catch (Exception exp)
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user