diff --git a/RMuseum/Controllers/GanjoorController.cs b/RMuseum/Controllers/GanjoorController.cs
index deb13154..e93196b2 100644
--- a/RMuseum/Controllers/GanjoorController.cs
+++ b/RMuseum/Controllers/GanjoorController.cs
@@ -16,6 +16,25 @@ namespace RMuseum.Controllers
[Route("api/ganjoor")]
public class GanjoorController : Controller
{
+ ///
+ /// get list of poets
+ ///
+ ///
+ ///
+ [HttpGet]
+ [Route("poets")]
+ [AllowAnonymous]
+ [ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(GanjoorPoet[]))]
+ [ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))]
+ public async Task GetPoets(bool websitePoets = true)
+ {
+ RServiceResult res =
+ await _ganjoorService.GetPoets(websitePoets);
+ if (!string.IsNullOrEmpty(res.ExceptionString))
+ return BadRequest(res.ExceptionString);
+ return Ok(res.Result);
+ }
+
///
/// get poem by id
///
diff --git a/RMuseum/RMuseum.xml b/RMuseum/RMuseum.xml
index 3fe60245..24b8e439 100644
--- a/RMuseum/RMuseum.xml
+++ b/RMuseum/RMuseum.xml
@@ -615,6 +615,13 @@
+
+
+ get list of poets
+
+
+
+
get poem by id
@@ -4435,6 +4442,13 @@
Ganjoor Poems Content Privider Service
+
+
+ Get List of poets
+
+
+
+
get poem by id
@@ -5174,6 +5188,13 @@
IGanjoorService implementation
+
+
+ Get List of poets
+
+
+
+
get poem by id
diff --git a/RMuseum/Services/IGanjoorService.cs b/RMuseum/Services/IGanjoorService.cs
index 3f8e0a4f..defdd3a5 100644
--- a/RMuseum/Services/IGanjoorService.cs
+++ b/RMuseum/Services/IGanjoorService.cs
@@ -12,6 +12,13 @@ namespace RMuseum.Services
///
public interface IGanjoorService
{
+ ///
+ /// Get List of poets
+ ///
+ ///
+ ///
+ Task> GetPoets(bool websitePoets);
+
///
/// get poem by id
///
diff --git a/RMuseum/Services/Implementation/GanjoorService.cs b/RMuseum/Services/Implementation/GanjoorService.cs
index c6df4053..85913218 100644
--- a/RMuseum/Services/Implementation/GanjoorService.cs
+++ b/RMuseum/Services/Implementation/GanjoorService.cs
@@ -23,6 +23,29 @@ namespace RMuseum.Services.Implementation
public class GanjoorService : IGanjoorService
{
+ ///
+ /// Get List of poets
+ ///
+ ///
+ ///
+ public async Task> GetPoets(bool websitePoets)
+ {
+ try
+ {
+ return new RServiceResult
+ (
+ await _context.GanjoorPoets
+ .Where(p => !websitePoets || p.Id < 200)
+ .OrderBy(p => p.Name)
+ .ToArrayAsync()
+ );
+ }
+ catch(Exception exp)
+ {
+ return new RServiceResult(null, exp.ToString());
+ }
+ }
+
///
/// get poem by id
///