poem by url api
This commit is contained in:
parent
6d4cfc5146
commit
ece5cf22d7
@ -157,6 +157,37 @@ namespace RMuseum.Controllers
|
||||
return Ok(res.Result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// get poem by url
|
||||
/// </summary>
|
||||
/// <param name="url"></param>
|
||||
/// <param name="catInfo"></param>
|
||||
/// <param name="catPoems"></param>
|
||||
/// <param name="rhymes">not implemented yet</param>
|
||||
/// <param name="recitations"></param>
|
||||
/// <param name="images"></param>
|
||||
/// <param name="songs">not implemented yet</param>
|
||||
/// <param name="comments">not implemented yet</param>
|
||||
/// <param name="verseDetails"></param>
|
||||
/// <param name="navigation">next/previous</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
[Route("poem")]
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(GanjoorPoemCompleteViewModel))]
|
||||
[ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))]
|
||||
[ProducesResponseType((int)HttpStatusCode.NotFound)]
|
||||
public async Task<IActionResult> GetPoemByUrl(string url, bool catInfo = true, bool catPoems = false, bool rhymes = true, bool recitations = true, bool images = true, bool songs = true, bool comments = true, bool verseDetails = true, bool navigation = true)
|
||||
{
|
||||
RServiceResult<GanjoorPoemCompleteViewModel> res =
|
||||
await _ganjoorService.GetPoemByUrl(url, catInfo, catPoems, rhymes, recitations, images, songs, comments, verseDetails, navigation);
|
||||
if (!string.IsNullOrEmpty(res.ExceptionString))
|
||||
return BadRequest(res.ExceptionString);
|
||||
if (res.Result == null)
|
||||
return NotFound();
|
||||
return Ok(res.Result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// get poem recitations (PlainText/HtmlText are intentionally empty)
|
||||
/// </summary>
|
||||
|
||||
@ -669,6 +669,22 @@
|
||||
<param name="navigation">next/previous</param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Controllers.GanjoorController.GetPoemByUrl(System.String,System.Boolean,System.Boolean,System.Boolean,System.Boolean,System.Boolean,System.Boolean,System.Boolean,System.Boolean,System.Boolean)">
|
||||
<summary>
|
||||
get poem by url
|
||||
</summary>
|
||||
<param name="url"></param>
|
||||
<param name="catInfo"></param>
|
||||
<param name="catPoems"></param>
|
||||
<param name="rhymes">not implemented yet</param>
|
||||
<param name="recitations"></param>
|
||||
<param name="images"></param>
|
||||
<param name="songs">not implemented yet</param>
|
||||
<param name="comments">not implemented yet</param>
|
||||
<param name="verseDetails"></param>
|
||||
<param name="navigation">next/previous</param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Controllers.GanjoorController.GetPoemRecitations(System.Int32)">
|
||||
<summary>
|
||||
get poem recitations (PlainText/HtmlText are intentionally empty)
|
||||
@ -4731,6 +4747,22 @@
|
||||
<param name="navigation"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.IGanjoorService.GetPoemByUrl(System.String,System.Boolean,System.Boolean,System.Boolean,System.Boolean,System.Boolean,System.Boolean,System.Boolean,System.Boolean,System.Boolean)">
|
||||
<summary>
|
||||
Get Poem By Url
|
||||
</summary>
|
||||
<param name="url"></param>
|
||||
<param name="catInfo"></param>
|
||||
<param name="catPoems"></param>
|
||||
<param name="rhymes"></param>
|
||||
<param name="recitations"></param>
|
||||
<param name="images"></param>
|
||||
<param name="songs"></param>
|
||||
<param name="comments"></param>
|
||||
<param name="verseDetails"></param>
|
||||
<param name="navigation"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.IGanjoorService.GetPoemRecitations(System.Int32)">
|
||||
<summary>
|
||||
get poem recitations (PlainText/HtmlText are intentionally empty)
|
||||
@ -5516,6 +5548,22 @@
|
||||
<param name="id"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.Implementation.GanjoorService.GetPoemByUrl(System.String,System.Boolean,System.Boolean,System.Boolean,System.Boolean,System.Boolean,System.Boolean,System.Boolean,System.Boolean,System.Boolean)">
|
||||
<summary>
|
||||
Get Poem By Url
|
||||
</summary>
|
||||
<param name="url"></param>
|
||||
<param name="catInfo"></param>
|
||||
<param name="catPoems"></param>
|
||||
<param name="rhymes"></param>
|
||||
<param name="recitations"></param>
|
||||
<param name="images"></param>
|
||||
<param name="songs"></param>
|
||||
<param name="comments"></param>
|
||||
<param name="verseDetails"></param>
|
||||
<param name="navigation"></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,System.Boolean,System.Boolean,System.Boolean)">
|
||||
<summary>
|
||||
Get Poem By Id
|
||||
|
||||
@ -67,6 +67,22 @@ namespace RMuseum.Services
|
||||
/// <returns></returns>
|
||||
Task<RServiceResult<GanjoorPoemCompleteViewModel>> GetPoemById(int id, bool catInfo = true, bool catPoems = false, bool rhymes = true, bool recitations = true, bool images = true, bool songs = true, bool comments = true, bool verseDetails = true, bool navigation = true);
|
||||
|
||||
/// <summary>
|
||||
/// Get Poem By Url
|
||||
/// </summary>
|
||||
/// <param name="url"></param>
|
||||
/// <param name="catInfo"></param>
|
||||
/// <param name="catPoems"></param>
|
||||
/// <param name="rhymes"></param>
|
||||
/// <param name="recitations"></param>
|
||||
/// <param name="images"></param>
|
||||
/// <param name="songs"></param>
|
||||
/// <param name="comments"></param>
|
||||
/// <param name="verseDetails"></param>
|
||||
/// <param name="navigation"></param>
|
||||
/// <returns></returns>
|
||||
Task<RServiceResult<GanjoorPoemCompleteViewModel>> GetPoemByUrl(string url, bool catInfo = true, bool catPoems = false, bool rhymes = true, bool recitations = true, bool images = true, bool songs = true, bool comments = true, bool verseDetails = true, bool navigation = true);
|
||||
|
||||
/// <summary>
|
||||
/// get poem recitations (PlainText/HtmlText are intentionally empty)
|
||||
/// </summary>
|
||||
|
||||
@ -373,6 +373,42 @@ namespace RMuseum.Services.Implementation
|
||||
return poemId;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get Poem By Url
|
||||
/// </summary>
|
||||
/// <param name="url"></param>
|
||||
/// <param name="catInfo"></param>
|
||||
/// <param name="catPoems"></param>
|
||||
/// <param name="rhymes"></param>
|
||||
/// <param name="recitations"></param>
|
||||
/// <param name="images"></param>
|
||||
/// <param name="songs"></param>
|
||||
/// <param name="comments"></param>
|
||||
/// <param name="verseDetails"></param>
|
||||
/// <param name="navigation"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<RServiceResult<GanjoorPoemCompleteViewModel>> GetPoemByUrl(string url, bool catInfo = true, bool catPoems = false, bool rhymes = true, bool recitations = true, bool images = true, bool songs = true, bool comments = true, bool verseDetails = true, bool navigation = true)
|
||||
{
|
||||
try
|
||||
{
|
||||
// /hafez/ => /hafez :
|
||||
if (url.LastIndexOf('/') == url.Length - 1)
|
||||
{
|
||||
url = url.Substring(0, url.Length - 1);
|
||||
}
|
||||
var poem = await _context.GanjoorPoems.Where(p => p.FullUrl == url).SingleOrDefaultAsync();
|
||||
if (poem == null)
|
||||
{
|
||||
return new RServiceResult<GanjoorPoemCompleteViewModel>(null); //not found
|
||||
}
|
||||
return await GetPoemById(poem.Id, catInfo, catPoems, rhymes, recitations, images, songs, comments, verseDetails, navigation);
|
||||
}
|
||||
catch(Exception exp)
|
||||
{
|
||||
return new RServiceResult<GanjoorPoemCompleteViewModel>(null, exp.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get Poem By Id
|
||||
/// </summary>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user