parent
2bb4265c51
commit
fec424ae56
@ -96,12 +96,55 @@
|
||||
@ViewData["Title"]
|
||||
</h2>
|
||||
|
||||
@if (Model.Quotes.Count == 0)
|
||||
@if (Model.Quotes.Count == 0 && Model.ClaimedQuotes.Count == 0)
|
||||
{
|
||||
<p>نقل قولی یافت نشد.</p>
|
||||
}
|
||||
else
|
||||
{
|
||||
@if(Model.ClaimedQuotes.Count > 0)
|
||||
{
|
||||
<div class="century">موارد منتسب به شاعران دیگر</div>
|
||||
|
||||
<ol>
|
||||
@foreach (var quotedPoem in Model.ClaimedQuotes)
|
||||
{
|
||||
<li>
|
||||
<h3>
|
||||
<a href="@quotedPoem.Poem.FullUrl">@quotedPoem.Poem.FullTitle</a> ::
|
||||
@if (string.IsNullOrEmpty(quotedPoem.CachedRelatedPoemFullUrl))
|
||||
{
|
||||
@quotedPoem.CachedRelatedPoemFullTitle
|
||||
}
|
||||
else
|
||||
{
|
||||
<a href="@quotedPoem.CachedRelatedPoemFullUrl">@quotedPoem.CachedRelatedPoemFullTitle</a>
|
||||
}
|
||||
</h3>
|
||||
<p>
|
||||
<a href="@quotedPoem.Poem.FullUrl">@quotedPoem.Poem.FullTitle</a>: @quotedPoem.CoupletVerse1 - @quotedPoem.CoupletVerse2
|
||||
</p>
|
||||
<p>
|
||||
@if (string.IsNullOrEmpty(quotedPoem.CachedRelatedPoemFullUrl))
|
||||
{
|
||||
@(quotedPoem.CachedRelatedPoemFullTitle)<text>: </text>
|
||||
}
|
||||
else
|
||||
{
|
||||
<a href="@quotedPoem.CachedRelatedPoemFullUrl">@quotedPoem.CachedRelatedPoemFullTitle</a><text>: </text>
|
||||
}
|
||||
@quotedPoem.RelatedCoupletVerse1 - @quotedPoem.RelatedCoupletVerse2
|
||||
</p>
|
||||
</li>
|
||||
}
|
||||
</ol>
|
||||
<br class="clear-both" />
|
||||
|
||||
<div class="century">نقل قولهای دیگر</div>
|
||||
}
|
||||
|
||||
|
||||
|
||||
<ol>
|
||||
@foreach (var quotedPoem in Model.Quotes)
|
||||
{
|
||||
@ -123,13 +166,13 @@
|
||||
<p>
|
||||
@if (string.IsNullOrEmpty(quotedPoem.CachedRelatedPoemFullUrl))
|
||||
{
|
||||
@quotedPoem.CachedRelatedPoemFullTitle
|
||||
@quotedPoem.CachedRelatedPoemFullTitle<text>: </text>
|
||||
}
|
||||
else
|
||||
{
|
||||
<a href="@quotedPoem.CachedRelatedPoemFullUrl">@quotedPoem.CachedRelatedPoemFullTitle</a>
|
||||
<a href="@quotedPoem.CachedRelatedPoemFullUrl">@quotedPoem.CachedRelatedPoemFullTitle</a><text>: </text>
|
||||
}
|
||||
: @quotedPoem.RelatedCoupletVerse1 - @quotedPoem.RelatedCoupletVerse2
|
||||
@quotedPoem.RelatedCoupletVerse1 - @quotedPoem.RelatedCoupletVerse2
|
||||
</p>
|
||||
</li>
|
||||
}
|
||||
|
||||
@ -17,9 +17,9 @@ namespace GanjooRazor.Pages
|
||||
Configuration = configuration;
|
||||
}
|
||||
public string LastError { get; set; }
|
||||
|
||||
public List<GanjoorPoetViewModel> Poets { get; set; }
|
||||
public GanjoorPoetViewModel Poet { get; set; }
|
||||
public List<GanjoorQuotedPoemViewModel> ClaimedQuotes { get; set; }
|
||||
public List<GanjoorQuotedPoemViewModel> Quotes { get; set; }
|
||||
|
||||
private async Task<bool> preparePoets()
|
||||
@ -66,7 +66,7 @@ namespace GanjooRazor.Pages
|
||||
{
|
||||
url += $"&poetId={Poet.Id}";
|
||||
}
|
||||
var responseQuotes = await _httpClient.GetAsync(url);
|
||||
var responseQuotes = await _httpClient.GetAsync(url + "&claimed=false");
|
||||
if (!responseQuotes.IsSuccessStatusCode)
|
||||
{
|
||||
LastError = JsonConvert.DeserializeObject<string>(await responseQuotes.Content.ReadAsStringAsync());
|
||||
@ -92,6 +92,32 @@ namespace GanjooRazor.Pages
|
||||
};
|
||||
}
|
||||
|
||||
var responseClaimedQuotes = await _httpClient.GetAsync(url + "&claimed=true");
|
||||
if (!responseClaimedQuotes.IsSuccessStatusCode)
|
||||
{
|
||||
LastError = JsonConvert.DeserializeObject<string>(await responseClaimedQuotes.Content.ReadAsStringAsync());
|
||||
return Page();
|
||||
}
|
||||
|
||||
ClaimedQuotes = JArray.Parse(await responseClaimedQuotes.Content.ReadAsStringAsync()).ToObject<List<GanjoorQuotedPoemViewModel>>();
|
||||
|
||||
foreach (var quote in ClaimedQuotes)
|
||||
{
|
||||
var poemQuery = await _httpClient.GetAsync($"{APIRoot.Url}/api/ganjoor/poem/{quote.PoemId}");
|
||||
if (!poemQuery.IsSuccessStatusCode)
|
||||
{
|
||||
LastError = JsonConvert.DeserializeObject<string>(await poemQuery.Content.ReadAsStringAsync());
|
||||
return Page();
|
||||
}
|
||||
var poem = JObject.Parse(await poemQuery.Content.ReadAsStringAsync()).ToObject<GanjoorPoemCompleteViewModel>();
|
||||
quote.Poem = new RMuseum.Models.Ganjoor.GanjoorPoem()
|
||||
{
|
||||
Id = poem.Id,
|
||||
FullTitle = poem.FullTitle,
|
||||
FullUrl = poem.FullUrl,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user