diff --git a/GanjooRazor/Areas/User/Pages/AllPoemSections.cshtml b/GanjooRazor/Areas/User/Pages/AllPoemSections.cshtml index 5e8c10b5..3541ad4b 100644 --- a/GanjooRazor/Areas/User/Pages/AllPoemSections.cshtml +++ b/GanjooRazor/Areas/User/Pages/AllPoemSections.cshtml @@ -13,6 +13,34 @@ } else { + @foreach (var poemSection in Model.PoemSections) { @@ -86,6 +114,15 @@ else @poemSection.RhymeLetters + + @if (poemSection.GanjoorMetre != null && !string.IsNullOrEmpty(poemSection.RhymeLetters) && Model.CanEdit) + { + + + + } }
+ شکستن از اینجا +
diff --git a/GanjooRazor/Areas/User/Pages/AllPoemSections.cshtml.cs b/GanjooRazor/Areas/User/Pages/AllPoemSections.cshtml.cs index a2118533..71fa8b65 100644 --- a/GanjooRazor/Areas/User/Pages/AllPoemSections.cshtml.cs +++ b/GanjooRazor/Areas/User/Pages/AllPoemSections.cshtml.cs @@ -1,4 +1,5 @@ -using System.Net.Http; +using System.Net.Http; +using System.Text; using System.Threading.Tasks; using GanjooRazor.Utils; using Microsoft.AspNetCore.Mvc; @@ -8,6 +9,7 @@ using RMuseum.Models.Ganjoor; namespace GanjooRazor.Areas.User.Pages { + [IgnoreAntiforgeryToken(Order = 1001)] public class AllPoemSectionsModel : PageModel { /// @@ -17,10 +19,16 @@ namespace GanjooRazor.Areas.User.Pages public GanjoorPoemSection[] PoemSections { get; set; } + /// + /// can edit + /// + public bool CanEdit { get; set; } + public async Task OnGetAsync() { if (string.IsNullOrEmpty(Request.Cookies["Token"])) return Redirect("/"); + CanEdit = Request.Cookies["CanEdit"] == "True"; using (HttpClient secureClient = new HttpClient()) { if (await GanjoorSessionChecker.PrepareClient(secureClient, Request, Response)) @@ -36,5 +44,29 @@ namespace GanjooRazor.Areas.User.Pages } return Page(); } + + + public async Task OnPostRebuildRelatedSectionsAsync(int meterId, string rhyming) + { + using (HttpClient secureClient = new HttpClient()) + { + if (await GanjoorSessionChecker.PrepareClient(secureClient, Request, Response)) + { + HttpResponseMessage response = await secureClient.PostAsync( + $"{APIRoot.Url}/api/ganjoor/sections/updaterelated?metreId={meterId}&rhyme={rhyming}", + null + ); + if (!response.IsSuccessStatusCode) + { + return new BadRequestObjectResult(JsonConvert.DeserializeObject(await response.Content.ReadAsStringAsync())); + } + return new OkObjectResult(JsonConvert.DeserializeObject(await response.Content.ReadAsStringAsync())); + } + else + { + return new BadRequestObjectResult("لطفا از گنجور خارج و مجددا به آن وارد شوید."); + } + } + } } } diff --git a/RMuseum/Controllers/GanjoorController.cs b/RMuseum/Controllers/GanjoorController.cs index 72eb7a04..04de349a 100644 --- a/RMuseum/Controllers/GanjoorController.cs +++ b/RMuseum/Controllers/GanjoorController.cs @@ -2804,7 +2804,7 @@ namespace RMuseum.Controllers /// [HttpPost] - [Route("startfindingmissingrhythms")] + [Route("sections/updaterelated")] [Authorize(Policy = RMuseumSecurableItem.GanjoorEntityShortName + ":" + SecurableItem.ModifyOperationShortName)] [ProducesResponseType((int)HttpStatusCode.OK)] [ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))]