From abf260803f7fce8618d3d2263bd708349fbdd6d6 Mon Sep 17 00:00:00 2001 From: Hamid Reza Mohammadi Date: Sat, 4 May 2024 17:42:13 +0330 Subject: [PATCH] #440 display a suggested photo in poets' home pages --- GanjooRazor/Pages/Index.cshtml.cs | 18 ++++++++ GanjooRazor/Pages/_GanjoorPagePartial.cshtml | 47 +++++++++++++++++++- 2 files changed, 64 insertions(+), 1 deletion(-) diff --git a/GanjooRazor/Pages/Index.cshtml.cs b/GanjooRazor/Pages/Index.cshtml.cs index 1c75d97e..c666654c 100644 --- a/GanjooRazor/Pages/Index.cshtml.cs +++ b/GanjooRazor/Pages/Index.cshtml.cs @@ -5,6 +5,7 @@ using Microsoft.AspNetCore.Mvc.ModelBinding; using Microsoft.AspNetCore.Mvc.ViewFeatures; using Microsoft.Extensions.Caching.Memory; using Microsoft.Extensions.Configuration; +using NAudio.Gui; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using RMuseum.Models.Ganjoor; @@ -627,6 +628,8 @@ namespace GanjooRazor.Pages } } + public GanjoorPoetSuggestedPictureViewModel Photo { get; set; } + /// /// Get /// @@ -737,6 +740,21 @@ namespace GanjooRazor.Pages CategoryHasRecitations = JsonConvert.DeserializeObject(await catHasAnyRecitationQuery.Content.ReadAsStringAsync()); } + if(IsPoetPage) + { + var responsePhotos = await _httpClient.GetAsync($"{APIRoot.Url}/api/poetphotos/poet/{GanjoorPage.PoetOrCat.Poet.Id}"); + if (!responsePhotos.IsSuccessStatusCode) + { + LastError = JsonConvert.DeserializeObject(await responsePhotos.Content.ReadAsStringAsync()); + return Page(); + } + var photos = JArray.Parse(await responsePhotos.Content.ReadAsStringAsync()).ToObject>(); + if(photos.Any()) + { + Photo = photos.First(); + } + } + if (IsPoemPage) { HtmlLanguage = string.IsNullOrEmpty(GanjoorPage.Poem.Language) ? "fa-IR" : GanjoorPage.Poem.Language; diff --git a/GanjooRazor/Pages/_GanjoorPagePartial.cshtml b/GanjooRazor/Pages/_GanjoorPagePartial.cshtml index 5346b891..0f60e906 100644 --- a/GanjooRazor/Pages/_GanjoorPagePartial.cshtml +++ b/GanjooRazor/Pages/_GanjoorPagePartial.cshtml @@ -292,7 +292,7 @@ { @($"[{poemGeoTag.Location.Latitude},{poemGeoTag.Location.Longitude}],") } - ]).addTo(map); + ]).addTo(map); for (var i = 0; i < poemGeoTags.length; i++) { var poemGeoTag = poemGeoTags[i]; @@ -402,6 +402,51 @@ } + @if (Model.IsPoetPage) + { + + + } + @if (Model.CanEdit && !Model.IsPoemPage) {