diff --git a/RMuseum/Controllers/GanjoorController.cs b/RMuseum/Controllers/GanjoorController.cs
index a783ecc0..563a6d35 100644
--- a/RMuseum/Controllers/GanjoorController.cs
+++ b/RMuseum/Controllers/GanjoorController.cs
@@ -3,6 +3,7 @@ using Microsoft.AspNetCore.Mvc;
using RMuseum.Models.Auth.Memory;
using RMuseum.Models.Ganjoor;
using RMuseum.Models.GanjoorAudio.ViewModels;
+using RMuseum.Models.GanjoorIntegration.ViewModels;
using RMuseum.Services;
using RSecurityBackend.Models.Generic;
using System.Net;
@@ -52,6 +53,25 @@ namespace RMuseum.Controllers
return Ok(res.Result);
}
+ ///
+ /// get poem images (PlainText/HtmlText are intentionally empty)
+ ///
+ ///
+ ///
+ [HttpGet]
+ [Route("poem/{id}/images")]
+ [AllowAnonymous]
+ [ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(GanjoorLinkViewModel[]))]
+ [ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))]
+ public async Task GetPoemImages(int id)
+ {
+ RServiceResult res =
+ await _ganjoorService.GetPoemImages(id);
+ if (!string.IsNullOrEmpty(res.ExceptionString))
+ return BadRequest(res.ExceptionString);
+ return Ok(res.Result);
+ }
+
///
/// imports data from ganjoor SQLite database
///
diff --git a/RMuseum/Models/GanjoorIntegration/ViewModels/GanjoorLinkViewModel.cs b/RMuseum/Models/GanjoorIntegration/ViewModels/GanjoorLinkViewModel.cs
index 70d71b56..e9fff5d8 100644
--- a/RMuseum/Models/GanjoorIntegration/ViewModels/GanjoorLinkViewModel.cs
+++ b/RMuseum/Models/GanjoorIntegration/ViewModels/GanjoorLinkViewModel.cs
@@ -8,6 +8,21 @@ namespace RMuseum.Models.GanjoorIntegration.ViewModels
///
public class GanjoorLinkViewModel
{
+ ///
+ /// default constructor
+ ///
+ public GanjoorLinkViewModel()
+ {
+
+ }
+
+ ///
+ /// parameterized constructor
+ ///
+ ///
+ ///
+ ///
+ ///
public GanjoorLinkViewModel(GanjoorLink src, string entityName, string entityFriendlyUrl, Guid entityImageId)
{
Id = src.Id;
diff --git a/RMuseum/RMuseum.xml b/RMuseum/RMuseum.xml
index 61f1bdac..0822084e 100644
--- a/RMuseum/RMuseum.xml
+++ b/RMuseum/RMuseum.xml
@@ -629,6 +629,13 @@
+
+
+ get poem images (PlainText/HtmlText are intentionally empty)
+
+
+
+
imports data from ganjoor SQLite database
@@ -2950,6 +2957,20 @@
Ganjoor Link View Model
+
+
+ default constructor
+
+
+
+
+ parameterized constructor
+
+
+
+
+
+
Id
@@ -4402,6 +4423,14 @@
+
+
+ get poem images by id (some fields are intentionally field with blank or null),
+ EntityImageId : the most important data field, image url is https://ganjgah.ir/api/images/thumb/{EntityImageId}.jpg or https://ganjgah.ir/api/images/norm/{EntityImageId}.jpg
+
+
+
+
imports unimported poem data from a locally accessible ganjoor SqlLite database
@@ -5127,6 +5156,14 @@
+
+
+ get poem images by id (some fields are intentionally field with blank or null),
+ EntityImageId : the most important data field, image url is https://ganjgah.ir/api/images/thumb/{EntityImageId}.jpg or https://ganjgah.ir/api/images/norm/{EntityImageId}.jpg
+
+
+
+
imports unimported poem data from a locally accessible ganjoor SqlLite database
diff --git a/RMuseum/Services/IGanjoorService.cs b/RMuseum/Services/IGanjoorService.cs
index 3d985c18..4a042e32 100644
--- a/RMuseum/Services/IGanjoorService.cs
+++ b/RMuseum/Services/IGanjoorService.cs
@@ -1,5 +1,6 @@
using RMuseum.Models.Ganjoor;
using RMuseum.Models.GanjoorAudio.ViewModels;
+using RMuseum.Models.GanjoorIntegration.ViewModels;
using RSecurityBackend.Models.Generic;
using System.Threading.Tasks;
@@ -24,6 +25,14 @@ namespace RMuseum.Services
///
Task> GetPoemRecitations(int id);
+ ///
+ /// get poem images by id (some fields are intentionally field with blank or null),
+ /// EntityImageId : the most important data field, image url is https://ganjgah.ir/api/images/thumb/{EntityImageId}.jpg or https://ganjgah.ir/api/images/norm/{EntityImageId}.jpg
+ ///
+ ///
+ ///
+ Task> GetPoemImages(int id);
+
///
/// imports unimported poem data from a locally accessible ganjoor SqlLite database
///
diff --git a/RMuseum/Services/Implementation/GanjoorService.cs b/RMuseum/Services/Implementation/GanjoorService.cs
index 167e3d99..a5aadff4 100644
--- a/RMuseum/Services/Implementation/GanjoorService.cs
+++ b/RMuseum/Services/Implementation/GanjoorService.cs
@@ -6,6 +6,7 @@ using RMuseum.DbContext;
using RMuseum.Models.Ganjoor;
using RMuseum.Models.GanjoorAudio;
using RMuseum.Models.GanjoorAudio.ViewModels;
+using RMuseum.Models.GanjoorIntegration.ViewModels;
using RSecurityBackend.Models.Generic;
using System;
using System.Data;
@@ -93,6 +94,45 @@ namespace RMuseum.Services.Implementation
}
}
+ ///
+ /// get poem images by id (some fields are intentionally field with blank or null),
+ /// EntityImageId : the most important data field, image url is https://ganjgah.ir/api/images/thumb/{EntityImageId}.jpg or https://ganjgah.ir/api/images/norm/{EntityImageId}.jpg
+ ///
+ ///
+ ///
+ public async Task> GetPoemImages(int id)
+ {
+ try
+ {
+ var source =
+ from link in _context.GanjoorLinks.Include(l => l.Item).ThenInclude(i => i.Images)
+ join poem in _context.GanjoorPoems
+ on link.GanjoorPostId equals poem.Id
+ where
+ link.ReviewResult == Models.GanjoorIntegration.ReviewResult.Approved
+ &&
+ poem.Id == id
+ orderby link.ReviewDate
+ select new GanjoorLinkViewModel()
+ {
+ Id = link.Id,
+ GanjoorPostId = link.GanjoorPostId,
+ GanjoorUrl = $"https://ganjoor.net{poem.FullUrl}",
+ GanjoorTitle = poem.FullTitle,
+ EntityName = "", //intentional
+ EntityFriendlyUrl = "", //intentional
+ EntityImageId = link.Item.Images.First().Id,//the most important data field, image url is https://ganjgah.ir/api/images/thumb/{EntityImageId}.jpg
+ ReviewResult = link.ReviewResult,
+ Synchronized = link.Synchronized,
+ SuggestedBy = null //intentional (this is going to be used in an anonymous method)
+ };
+ return new RServiceResult(await source.ToArrayAsync());
+ }
+ catch (Exception exp)
+ {
+ return new RServiceResult(null, exp.ToString());
+ }
+ }
#region Date import / modifications
///