diff --git a/GanjooRazor/Areas/User/Pages/Section.cshtml b/GanjooRazor/Areas/User/Pages/Section.cshtml index 0d7eaa00..913f9b27 100644 --- a/GanjooRazor/Areas/User/Pages/Section.cshtml +++ b/GanjooRazor/Areas/User/Pages/Section.cshtml @@ -98,6 +98,27 @@ else }); + + } + + function computeSectionRhyme(sectionId, elementId) { + $.ajax({ + type: "GET", + url: '?Handler=ComputeRhyme', + data: { + id: sectionId + }, + error: function(e) { + if (e.responseText == null) + alert(e); + else + alert(e.responseText); + }, + success: function(rhyme) { + $(elementId).val(rhyme); + return false; + }, + }); }

@Model.PageInformation.FullTitle

@@ -246,6 +267,7 @@ else { } + محاسبه diff --git a/GanjooRazor/Areas/User/Pages/Section.cshtml.cs b/GanjooRazor/Areas/User/Pages/Section.cshtml.cs index 8566f2da..13bdca9b 100644 --- a/GanjooRazor/Areas/User/Pages/Section.cshtml.cs +++ b/GanjooRazor/Areas/User/Pages/Section.cshtml.cs @@ -302,5 +302,26 @@ namespace GanjooRazor.Areas.User.Pages } } } + + public async Task OnGetComputeRhymeAsync(int id) + { + using (HttpClient secureClient = new HttpClient()) + { + if (await GanjoorSessionChecker.PrepareClient(secureClient, Request, Response)) + { + var response = await secureClient.GetAsync($"{APIRoot.Url}/api/ganjoor/section/analyserhyme/{id}"); + if (!response.IsSuccessStatusCode) + { + return new BadRequestObjectResult(JsonConvert.DeserializeObject(await response.Content.ReadAsStringAsync())); + } + var rhyme = JsonConvert.DeserializeObject(await response.Content.ReadAsStringAsync()); + return new OkObjectResult(rhyme.Rhyme); + } + else + { + return new BadRequestObjectResult("لطفا از گنجور خارج و مجددا به آن وارد شوید."); + } + } + } } }