#160 find poem rhymes inside modfy page

This commit is contained in:
Hamid Reza Mohammadi 2021-06-25 09:49:33 +04:30
parent 40516404db
commit 3a0bca2427
3 changed files with 26 additions and 1 deletions

View File

@ -98,7 +98,7 @@
</td>
<td>
<input asp-for="ModifyModel.RhymeLetters" />
<a role="button" onclick="computePoemRhyme(@Request.Query["id"], '#ModifyModel_RhymeLetters')" class="actionlink">محاسبه</a>
</td>
</tr>
<tr>

View File

@ -107,6 +107,14 @@ namespace GanjooRazor.Areas.Admin.Pages
return Page();
}
public async Task<IActionResult> OnGetComputeRhymeAsync(int id)
{
var response = await _httpClient.GetAsync($"{APIRoot.Url}/api/ganjoor/poem/analysisrhyme/{id}");
response.EnsureSuccessStatusCode();
var rhyme = JsonConvert.DeserializeObject<GanjooRhymeAnalysisResult>(await response.Content.ReadAsStringAsync());
return new OkObjectResult(rhyme.Rhyme);
}
public async Task<IActionResult> OnPostAsync(GanjoorModifyPageViewModel ModifyModel)
{
using (HttpClient secureClient = new HttpClient())

View File

@ -167,6 +167,23 @@
});
}
function computePoemRhyme(poemId, elementId) {
$.ajax({
type: "GET",
url: '?Handler=ComputeRhyme',
data: {
id: poemId
},
error: function () {
alert('خطا رخ داد.');
},
success: function (rhyme) {
$(elementId).val(rhyme);
return false;
},
});
}
</script>
</head>