refillcoupletindices
This commit is contained in:
parent
e1b11b0c59
commit
2fb283421c
@ -324,6 +324,32 @@
|
||||
document.getElementById('secondr-btn').style.display = 'none';
|
||||
}
|
||||
|
||||
function updateCoupletIndices(id){
|
||||
if (!confirm('آیا از بازسازی اندیسهای ابیات اطمینان دارید؟'))
|
||||
return;
|
||||
|
||||
|
||||
var url = '?handler=RefillCoupletIndices';
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: url,
|
||||
data: {
|
||||
id: id,
|
||||
},
|
||||
error: function (e) {
|
||||
if (e.responseText == null)
|
||||
alert(e);
|
||||
else
|
||||
alert(e.responseText);
|
||||
},
|
||||
success: function () {
|
||||
alert('انجام شد.');
|
||||
},
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
function regenerateSections(id) {
|
||||
if (!confirm('آیا از قطعهبندی مجدد اطمینان دارید؟'))
|
||||
return;
|
||||
@ -1646,6 +1672,13 @@ else
|
||||
</tr>
|
||||
}
|
||||
|
||||
@if (Model.ShowAdminOps)
|
||||
{
|
||||
<tr>
|
||||
<td><a role="button" onclick="updateCoupletIndices(@Model.PageInformation.Poem.Id)" class="pagebutton">تصحیح اندیسهای ابیات</a></td>
|
||||
</tr>
|
||||
}
|
||||
|
||||
@if (Model.ShowAdminOps)
|
||||
{
|
||||
<tr>
|
||||
|
||||
@ -548,6 +548,29 @@ namespace GanjooRazor.Areas.User.Pages
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnPostRefillCoupletIndicesAsync(int id)
|
||||
{
|
||||
using (HttpClient secureClient = new HttpClient())
|
||||
{
|
||||
if (await GanjoorSessionChecker.PrepareClient(secureClient, Request, Response))
|
||||
{
|
||||
HttpResponseMessage response = await secureClient.PostAsync(
|
||||
$"{APIRoot.Url}/api/ganjoor/refillcoupletindices/{id}",
|
||||
null
|
||||
);
|
||||
if (!response.IsSuccessStatusCode)
|
||||
{
|
||||
return new BadRequestObjectResult(JsonConvert.DeserializeObject<string>(await response.Content.ReadAsStringAsync()));
|
||||
}
|
||||
return new OkResult();
|
||||
}
|
||||
else
|
||||
{
|
||||
return new BadRequestObjectResult("لطفاً از گنجور خارج و مجددا به آن وارد شوید.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnPostRegeneratePoemSectionsAsync(int id)
|
||||
{
|
||||
using (HttpClient secureClient = new HttpClient())
|
||||
|
||||
@ -2616,6 +2616,27 @@ namespace RMuseum.Controllers
|
||||
return BadRequest(res.ExceptionString);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// refill couplet indices for poem
|
||||
/// </summary>
|
||||
/// <param name="poemId"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Route("refillcoupletindices/{poemId}")]
|
||||
[Authorize(Policy = RMuseumSecurableItem.GanjoorEntityShortName + ":" + RMuseumSecurableItem.ImportOperationShortName)]
|
||||
[ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(bool))]
|
||||
[ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))]
|
||||
public async Task<IActionResult> RefillCoupletIndicesAsync(int poemId)
|
||||
{
|
||||
RServiceResult<bool> res =
|
||||
await _ganjoorService.RefillCoupletIndicesAsync(poemId);
|
||||
if (!string.IsNullOrEmpty(res.ExceptionString))
|
||||
{
|
||||
return BadRequest(res.ExceptionString);
|
||||
}
|
||||
return Ok();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// fill section couplet counts
|
||||
/// </summary>
|
||||
|
||||
@ -1747,6 +1747,13 @@
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Controllers.GanjoorController.RefillCoupletIndicesAsync(System.Int32)">
|
||||
<summary>
|
||||
refill couplet indices for poem
|
||||
</summary>
|
||||
<param name="poemId"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Controllers.GanjoorController.StartFillingSectionCoupletCounts">
|
||||
<summary>
|
||||
fill section couplet counts
|
||||
@ -16586,6 +16593,13 @@
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.IGanjoorService.RefillCoupletIndicesAsync(System.Int32)">
|
||||
<summary>
|
||||
refill couplet indices
|
||||
</summary>
|
||||
<param name="poemId"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.IGanjoorService.StartFillingSectionCoupletCounts">
|
||||
<summary>
|
||||
fill section couplets count
|
||||
@ -19393,6 +19407,13 @@
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.Implementation.GanjoorService.RefillCoupletIndicesAsync(System.Int32)">
|
||||
<summary>
|
||||
refill couplet indices
|
||||
</summary>
|
||||
<param name="poemId"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.Implementation.GanjoorService.StartFillingSectionCoupletCounts">
|
||||
<summary>
|
||||
fill section couplets count
|
||||
|
||||
@ -628,6 +628,13 @@ namespace RMuseum.Services
|
||||
/// <returns></returns>
|
||||
RServiceResult<bool> StartFillingPoemsCoupletIndices();
|
||||
|
||||
/// <summary>
|
||||
/// refill couplet indices
|
||||
/// </summary>
|
||||
/// <param name="poemId"></param>
|
||||
/// <returns></returns>
|
||||
Task<RServiceResult<bool>> RefillCoupletIndicesAsync(int poemId);
|
||||
|
||||
/// <summary>
|
||||
/// fill section couplets count
|
||||
/// </summary>
|
||||
|
||||
@ -692,6 +692,25 @@ namespace RMuseum.Services.Implementation
|
||||
return new RServiceResult<bool>(true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// refill couplet indices
|
||||
/// </summary>
|
||||
/// <param name="poemId"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<RServiceResult<bool>> RefillCoupletIndicesAsync(int poemId)
|
||||
{
|
||||
try
|
||||
{
|
||||
await _FillPoemCoupletIndices(_context, poemId);
|
||||
await _context.SaveChangesAsync();
|
||||
return new RServiceResult<bool>(false);
|
||||
}
|
||||
catch (Exception exp)
|
||||
{
|
||||
return new RServiceResult<bool>(false, exp.ToString() );
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// fill section couplets count
|
||||
/// </summary>
|
||||
|
||||
@ -120,6 +120,7 @@ namespace RMuseum.Services.Implementation
|
||||
if (moderation.VerseOrderText.Length != dbCorrection.VerseOrderText.Count)
|
||||
return new RServiceResult<GanjoorPoemCorrectionViewModel>(null, "moderation.VerseOrderText.Length != dbCorrection.VerseOrderText.Count");
|
||||
|
||||
bool versePosistionsChanged = false;
|
||||
var modifiedVerses = new List<GanjoorVerse>();
|
||||
|
||||
foreach (var moderatedVerse in moderation.VerseOrderText)
|
||||
@ -135,6 +136,7 @@ namespace RMuseum.Services.Implementation
|
||||
{
|
||||
if (moderatedVerse.VersePositionResult == CorrectionReviewResult.NotReviewed)
|
||||
return new RServiceResult<GanjoorPoemCorrectionViewModel>(null, $"تغییرات نوع مصرع {moderatedVerse.VORder} بررسی نشده است.");
|
||||
versePosistionsChanged = true;
|
||||
dbVerse.VersePositionResult = moderatedVerse.VersePositionResult;
|
||||
}
|
||||
if(dbVerse.CoupletSummary != null)
|
||||
@ -284,7 +286,7 @@ namespace RMuseum.Services.Implementation
|
||||
await _context.SaveChangesAsync();//temporary ids should be saved
|
||||
}
|
||||
|
||||
if (versesDeleted || verseAdded)
|
||||
if (versesDeleted || verseAdded || versePosistionsChanged)
|
||||
{
|
||||
var undeletedPoemVerss = poemVerses.OrderBy(v => v.VOrder).Where(v => !moderation.VerseOrderText.Any(mv => mv.VORder == v.VOrder && mv.MarkForDelete == true)).ToList();
|
||||
for (int vOrder = 1; vOrder <= undeletedPoemVerss.Count; vOrder++)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user