This commit is contained in:
Hamid Reza Mohammadi 2020-12-20 20:46:42 +03:30
parent c93b44ecd8
commit 8963740a8c
4 changed files with 70 additions and 0 deletions

View File

@ -16,6 +16,25 @@ namespace RMuseum.Controllers
[Route("api/ganjoor")]
public class GanjoorController : Controller
{
/// <summary>
/// get list of poets
/// </summary>
/// <param name="websitePoets"></param>
/// <returns></returns>
[HttpGet]
[Route("poets")]
[AllowAnonymous]
[ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(GanjoorPoet[]))]
[ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))]
public async Task<IActionResult> GetPoets(bool websitePoets = true)
{
RServiceResult<GanjoorPoet[]> res =
await _ganjoorService.GetPoets(websitePoets);
if (!string.IsNullOrEmpty(res.ExceptionString))
return BadRequest(res.ExceptionString);
return Ok(res.Result);
}
/// <summary>
/// get poem by id
/// </summary>

View File

@ -615,6 +615,13 @@
<param name="auditLogService">
</param>
</member>
<member name="M:RMuseum.Controllers.GanjoorController.GetPoets(System.Boolean)">
<summary>
get list of poets
</summary>
<param name="websitePoets"></param>
<returns></returns>
</member>
<member name="M:RMuseum.Controllers.GanjoorController.GetPoemById(System.Int32)">
<summary>
get poem by id
@ -4435,6 +4442,13 @@
Ganjoor Poems Content Privider Service
</summary>
</member>
<member name="M:RMuseum.Services.IGanjoorService.GetPoets(System.Boolean)">
<summary>
Get List of poets
</summary>
<param name="websitePoets"></param>
<returns></returns>
</member>
<member name="M:RMuseum.Services.IGanjoorService.GetPoemById(System.Int32)">
<summary>
get poem by id
@ -5174,6 +5188,13 @@
IGanjoorService implementation
</summary>
</member>
<member name="M:RMuseum.Services.Implementation.GanjoorService.GetPoets(System.Boolean)">
<summary>
Get List of poets
</summary>
<param name="websitePoets"></param>
<returns></returns>
</member>
<member name="M:RMuseum.Services.Implementation.GanjoorService.GetPoemById(System.Int32)">
<summary>
get poem by id

View File

@ -12,6 +12,13 @@ namespace RMuseum.Services
/// </summary>
public interface IGanjoorService
{
/// <summary>
/// Get List of poets
/// </summary>
/// <param name="websitePoets"></param>
/// <returns></returns>
Task<RServiceResult<GanjoorPoet[]>> GetPoets(bool websitePoets);
/// <summary>
/// get poem by id
/// </summary>

View File

@ -23,6 +23,29 @@ namespace RMuseum.Services.Implementation
public class GanjoorService : IGanjoorService
{
/// <summary>
/// Get List of poets
/// </summary>
/// <param name="websitePoets"></param>
/// <returns></returns>
public async Task<RServiceResult<GanjoorPoet[]>> GetPoets(bool websitePoets)
{
try
{
return new RServiceResult<GanjoorPoet[]>
(
await _context.GanjoorPoets
.Where(p => !websitePoets || p.Id < 200)
.OrderBy(p => p.Name)
.ToArrayAsync()
);
}
catch(Exception exp)
{
return new RServiceResult<GanjoorPoet[]>(null, exp.ToString());
}
}
/// <summary>
/// get poem by id
/// </summary>