diff --git a/RMuseum/Controllers/GanjoorController.cs b/RMuseum/Controllers/GanjoorController.cs
index e47acd43..49eee995 100644
--- a/RMuseum/Controllers/GanjoorController.cs
+++ b/RMuseum/Controllers/GanjoorController.cs
@@ -154,6 +154,28 @@ namespace RMuseum.Controllers
return Ok(res.Result);
}
+ ///
+ /// page url by id
+ ///
+ ///
+ ///
+ [HttpGet]
+ [Route("pageurl")]
+ [AllowAnonymous]
+ [ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(string))]
+ [ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))]
+ [ProducesResponseType((int)HttpStatusCode.NotFound)]
+ public async Task GetPageUrlById(int id)
+ {
+ RServiceResult res =
+ await _ganjoorService.GetPageUrlById(id);
+ if (!string.IsNullOrEmpty(res.ExceptionString))
+ return BadRequest(res.ExceptionString);
+ if (string.IsNullOrEmpty(res.Result))
+ return NotFound();
+ return Ok(res.Result);
+ }
+
///
/// get poem by id
///
diff --git a/RMuseum/RMuseum.xml b/RMuseum/RMuseum.xml
index 6883e81c..7e54fc17 100644
--- a/RMuseum/RMuseum.xml
+++ b/RMuseum/RMuseum.xml
@@ -661,6 +661,13 @@
+
+
+ page url by id
+
+
+
+
get poem by id
@@ -5889,6 +5896,13 @@
+
+
+ get page url by id
+
+
+
+
Get Poem By Id
@@ -6763,6 +6777,13 @@
+
+
+ get page url by id
+
+
+
+
get page by url
diff --git a/RMuseum/Services/IGanjoorService.cs b/RMuseum/Services/IGanjoorService.cs
index 2780c116..96e2f5c0 100644
--- a/RMuseum/Services/IGanjoorService.cs
+++ b/RMuseum/Services/IGanjoorService.cs
@@ -59,6 +59,13 @@ namespace RMuseum.Services
///
Task> GetPageByUrl(string url, bool catPoems = true);
+ ///
+ /// get page url by id
+ ///
+ ///
+ ///
+ Task> GetPageUrlById(int id);
+
///
/// Get Poem By Id
///
diff --git a/RMuseum/Services/Implementation/GanjoorService.cs b/RMuseum/Services/Implementation/GanjoorService.cs
index ca8a61e8..c1122e92 100644
--- a/RMuseum/Services/Implementation/GanjoorService.cs
+++ b/RMuseum/Services/Implementation/GanjoorService.cs
@@ -272,6 +272,26 @@ namespace RMuseum.Services.Implementation
}
}
+ ///
+ /// get page url by id
+ ///
+ ///
+ ///
+ public async Task> GetPageUrlById(int id)
+ {
+ try
+ {
+ var dbPage = await _context.GanjoorPages.Where(p => p.Id == id).SingleOrDefaultAsync();
+ if (dbPage == null)
+ return new RServiceResult(null); //not found
+ return new RServiceResult(dbPage.FullUrl);
+ }
+ catch(Exception exp)
+ {
+ return new RServiceResult(null, exp.ToString());
+ }
+ }
+
///
/// get page by url
///