Projects (GanjooRazor -> DiwanRazor, GanjoorService.sln -> DiwanService.sln), files, folders, classes, namespaces, settings, API routes (/api/diwan) and DB tables (Diwan*). External addresses (ganjoor.net, github.com/ganjoor) unchanged. Migrations renamed consistently (no pending model changes); requires a fresh database. Upstream RUNNING_LOCALLY/SEMANTIC_SEARCH docs archived unmodified under docs/. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
66 lines
2.0 KiB
C#
66 lines
2.0 KiB
C#
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.AspNetCore.Mvc.RazorPages;
|
|
using System.Net.Http;
|
|
using System.Threading.Tasks;
|
|
using Newtonsoft.Json;
|
|
using RMuseum.Models.Diwan.ViewModels;
|
|
using Microsoft.Extensions.Configuration;
|
|
|
|
namespace DiwanRazor.Pages
|
|
{
|
|
public class t6eModel : PageModel
|
|
{
|
|
/// <summary>
|
|
/// poem
|
|
/// </summary>
|
|
public DiwanPoemCompleteViewModel Poem { get; set; }
|
|
|
|
/// <summary>
|
|
/// last error
|
|
/// </summary>
|
|
public string LastError { get; set; }
|
|
|
|
public async Task<IActionResult> OnGetAsync()
|
|
{
|
|
if (bool.Parse(Configuration["MaintenanceMode"]))
|
|
{
|
|
return StatusCode(503);
|
|
}
|
|
|
|
var responsePoem = await _httpClient.GetAsync($"{APIRoot.Url}/api/diwan/poem/{Request.Query["p"]}?verseDetails=true&catInfo=false&rhymes=false&recitations=false&images=false&songs=false&comments=false&navigation=false");
|
|
if (!responsePoem.IsSuccessStatusCode)
|
|
{
|
|
LastError = JsonConvert.DeserializeObject<string>(await responsePoem.Content.ReadAsStringAsync());
|
|
return Page();
|
|
}
|
|
|
|
Poem = JsonConvert.DeserializeObject<DiwanPoemCompleteViewModel>(await responsePoem.Content.ReadAsStringAsync());
|
|
return Page();
|
|
}
|
|
|
|
/// <summary>
|
|
/// HttpClient instance
|
|
/// </summary>
|
|
private readonly HttpClient _httpClient;
|
|
|
|
/// <summary>
|
|
/// configration file reader (appsettings.json)
|
|
/// </summary>
|
|
private readonly IConfiguration Configuration;
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// constructor
|
|
/// </summary>
|
|
/// <param name="httpClient"></param>
|
|
/// <param name="configuration"></param>
|
|
public t6eModel(HttpClient httpClient, IConfiguration configuration)
|
|
{
|
|
_httpClient = httpClient;
|
|
Configuration
|
|
= configuration;
|
|
}
|
|
}
|
|
}
|