From 83ba58fb6e25ab085c1097b56c7bd80fc4732cad Mon Sep 17 00:00:00 2001 From: Hamid Reza Mohammadi Date: Fri, 20 May 2022 08:40:52 +0430 Subject: [PATCH] docs: #319 restoring the ability to break a section from 4 places --- .../Areas/Admin/Pages/ReviewPartEdits.cshtml | 4 +- GanjooRazor/Areas/User/Pages/Section.cshtml | 4 +- ...anjoorService-ModerateSectionCorrection.cs | 49 ++++++++++++++++++- 3 files changed, 52 insertions(+), 5 deletions(-) diff --git a/GanjooRazor/Areas/Admin/Pages/ReviewPartEdits.cshtml b/GanjooRazor/Areas/Admin/Pages/ReviewPartEdits.cshtml index def69bc5..cd423acb 100644 --- a/GanjooRazor/Areas/Admin/Pages/ReviewPartEdits.cshtml +++ b/GanjooRazor/Areas/Admin/Pages/ReviewPartEdits.cshtml @@ -34,8 +34,8 @@ else } } - if (breakFromVIndices.length > 1) { - alert('حداکثر از ۱ محل می‌توانید قطعه را بشکنید.'); + if (breakFromVIndices.length > 4) { + alert('حداکثر از ۴ محل می‌توانید قطعه را بشکنید.'); return; } diff --git a/GanjooRazor/Areas/User/Pages/Section.cshtml b/GanjooRazor/Areas/User/Pages/Section.cshtml index 3749ae54..3cfb7f19 100644 --- a/GanjooRazor/Areas/User/Pages/Section.cshtml +++ b/GanjooRazor/Areas/User/Pages/Section.cshtml @@ -25,8 +25,8 @@ else } } - if (breakFromVIndices.length > 1) { - alert('حداکثر از ۱ محل می‌توانید قطعه را بشکنید.'); + if (breakFromVIndices.length > 4) { + alert('حداکثر از ۴ محل می‌توانید قطعه را بشکنید.'); return; } diff --git a/RMuseum/Services/Implementation/GanjoorService-Partials/GanjoorService-ModerateSectionCorrection.cs b/RMuseum/Services/Implementation/GanjoorService-Partials/GanjoorService-ModerateSectionCorrection.cs index 8f230534..f9782e9f 100644 --- a/RMuseum/Services/Implementation/GanjoorService-Partials/GanjoorService-ModerateSectionCorrection.cs +++ b/RMuseum/Services/Implementation/GanjoorService-Partials/GanjoorService-ModerateSectionCorrection.cs @@ -90,6 +90,54 @@ namespace RMuseum.Services.Implementation } } + if (dbCorrection.BreakFromVerse4VOrder != null) + { + if (moderation.BreakFromVerse4VOrder != dbCorrection.BreakFromVerse4VOrder) + { + dbCorrection.BreakFromVerse4VOrderResult = CorrectionReviewResult.RejectedBecauseWrong; + dbCorrection.BreakFromVerse4VOrder = null; + } + else + { + await _BreakSection(sections, editingSectionNotTracked, (int)dbCorrection.BreakFromVerse4VOrder); + dbCorrection.BreakFromVerse4VOrderResult = CorrectionReviewResult.Approved; + _context.GanjoorPoemSectionCorrections.Update(dbCorrection); + await _context.SaveChangesAsync(); + } + } + + if (dbCorrection.BreakFromVerse3VOrder != null) + { + if (moderation.BreakFromVerse3VOrder != dbCorrection.BreakFromVerse3VOrder) + { + dbCorrection.BreakFromVerse3VOrderResult = CorrectionReviewResult.RejectedBecauseWrong; + dbCorrection.BreakFromVerse3VOrder = null; + } + else + { + await _BreakSection(sections, editingSectionNotTracked, (int)dbCorrection.BreakFromVerse3VOrder); + dbCorrection.BreakFromVerse3VOrderResult = CorrectionReviewResult.Approved; + _context.GanjoorPoemSectionCorrections.Update(dbCorrection); + await _context.SaveChangesAsync(); + } + } + + if (dbCorrection.BreakFromVerse2VOrder != null) + { + if (moderation.BreakFromVerse2VOrder != dbCorrection.BreakFromVerse2VOrder) + { + dbCorrection.BreakFromVerse2VOrderResult = CorrectionReviewResult.RejectedBecauseWrong; + dbCorrection.BreakFromVerse2VOrder = null; + } + else + { + await _BreakSection(sections, editingSectionNotTracked, (int)dbCorrection.BreakFromVerse2VOrder); + dbCorrection.BreakFromVerse2VOrderResult = CorrectionReviewResult.Approved; + _context.GanjoorPoemSectionCorrections.Update(dbCorrection); + await _context.SaveChangesAsync(); + } + } + if (dbCorrection.BreakFromVerse1VOrder != null) { if (moderation.BreakFromVerse1VOrder != dbCorrection.BreakFromVerse1VOrder) @@ -105,7 +153,6 @@ namespace RMuseum.Services.Implementation await _context.SaveChangesAsync(); } } - _context.GanjoorPoemSectionCorrections.Update(dbCorrection); await _context.SaveChangesAsync();