docs: #275 getting list of poet speclines in the UI

This commit is contained in:
Hamid Reza Mohammadi 2022-01-31 19:58:22 +03:30
parent aa754469b4
commit 5253aa8e9f
2 changed files with 25 additions and 1 deletions

View File

@ -91,6 +91,21 @@
<div class="clear-both">
@Model.Poet.Description
</div>
<div class="century">
نکات مهم دربارهٔ @Model.Poet.Nickname
</div>
@foreach (var line in Model.SpecLines)
{
<div class="clear-both">
@line.Contents
</div>
}
<div class="clear-both">
<p>شما نکته‌ای اضافه کنید</p>
</div>
}

View File

@ -18,6 +18,8 @@ namespace GanjooRazor.Pages
public GanjoorPoetViewModel Poet { get; set; }
public List<GanjoorPoetSuggestedSpecLineViewModel> SpecLines { get; set; }
private async Task<List<GanjoorPoetViewModel>> _PreparePoets()
{
var response = await _httpClient.GetAsync($"{APIRoot.Url}/api/ganjoor/poets");
@ -28,7 +30,6 @@ namespace GanjooRazor.Pages
}
var poets = JArray.Parse(await response.Content.ReadAsStringAsync()).ToObject<List<GanjoorPoetViewModel>>();
foreach (var poet in poets)
{
poet.ImageUrl = $"{APIRoot.InternetUrl}{poet.ImageUrl}";
@ -51,6 +52,14 @@ namespace GanjooRazor.Pages
}
Poet = JObject.Parse(await response.Content.ReadAsStringAsync()).ToObject<GanjoorPoetCompleteViewModel>().Poet;
Poet.ImageUrl = $"{APIRoot.InternetUrl}{Poet.ImageUrl}";
var responseLines = await _httpClient.GetAsync($"{APIRoot.Url}/api/poetspecs/poet/{Poet.Id}");
if (!responseLines.IsSuccessStatusCode)
{
LastError = JsonConvert.DeserializeObject<string>(await responseLines.Content.ReadAsStringAsync());
return Page();
}
SpecLines = JArray.Parse(await responseLines.Content.ReadAsStringAsync()).ToObject<List<GanjoorPoetSuggestedSpecLineViewModel>>();
}
else
{