#421 geo tag suggestion
This commit is contained in:
parent
f5f6ddf5b1
commit
ce05b9be0e
@ -283,6 +283,48 @@ namespace GanjooRazor.Areas.User.Pages
|
||||
correction.PoemSummary = currentCorrection.SummaryReviewResult == CorrectionReviewResult.Approved && currentCorrection.PoemSummary != null ? currentCorrection.OriginalPoemSummary ?? "" : null;
|
||||
correction.OriginalPoemSummary = currentCorrection.SummaryReviewResult == CorrectionReviewResult.Approved && currentCorrection.PoemSummary != null ? currentCorrection.PoemSummary : null;
|
||||
|
||||
if (currentCorrection.GeoDateTags != null)
|
||||
{
|
||||
var geoDateTagsRollback = new List<GanjoorPoemGeoDateTagCorrection>();
|
||||
foreach (var geoTag in currentCorrection.GeoDateTags.Where(g => g.Result == CorrectionReviewResult.Approved))
|
||||
{
|
||||
if (geoTag.MarkForDelete)
|
||||
{
|
||||
// the original request deleted an existing tag - undo that by re-adding a tag with
|
||||
// the same data, which was snapshotted onto this same record when it was approved
|
||||
// (LocationId/LunarYear/etc. are otherwise unused for a pure delete-request)
|
||||
geoDateTagsRollback.Add(new GanjoorPoemGeoDateTagCorrection()
|
||||
{
|
||||
CoupletIndex = geoTag.CoupletIndex,
|
||||
MarkForDelete = false,
|
||||
LocationId = geoTag.LocationId,
|
||||
LunarYear = geoTag.LunarYear,
|
||||
LunarMonth = geoTag.LunarMonth,
|
||||
LunarDay = geoTag.LunarDay,
|
||||
PersonId = geoTag.PersonId,
|
||||
IgnoreInCategory = geoTag.IgnoreInCategory,
|
||||
SuggestionNote = $"برگشت حذف برچسب جغرافیایی/تاریخی با کد {correctionId}"
|
||||
});
|
||||
}
|
||||
else if (geoTag.ExistingTagId != null)
|
||||
{
|
||||
// the original request added a new tag - undo that by requesting deletion of the
|
||||
// live tag it produced (its id was recorded onto ExistingTagId when approved)
|
||||
geoDateTagsRollback.Add(new GanjoorPoemGeoDateTagCorrection()
|
||||
{
|
||||
CoupletIndex = geoTag.CoupletIndex,
|
||||
MarkForDelete = true,
|
||||
ExistingTagId = geoTag.ExistingTagId,
|
||||
SuggestionNote = $"برگشت افزودن برچسب جغرافیایی/تاریخی با کد {correctionId}"
|
||||
});
|
||||
}
|
||||
}
|
||||
if (geoDateTagsRollback.Count > 0)
|
||||
{
|
||||
correction.GeoDateTags = geoDateTagsRollback.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
correction.Note = $"برگشت تصحیح با کد {correctionId}";
|
||||
if(!string.IsNullOrEmpty(currentCorrection.Note))
|
||||
{
|
||||
|
||||
@ -243,6 +243,48 @@ namespace GanjooRazor.Areas.User.Pages
|
||||
correction.PoemSummary = currentCorrection.SummaryReviewResult == CorrectionReviewResult.Approved && currentCorrection.PoemSummary != null ? currentCorrection.OriginalPoemSummary ?? "" : null;
|
||||
correction.OriginalPoemSummary = currentCorrection.SummaryReviewResult == CorrectionReviewResult.Approved && currentCorrection.PoemSummary != null ? currentCorrection.PoemSummary : null;
|
||||
|
||||
if (currentCorrection.GeoDateTags != null)
|
||||
{
|
||||
var geoDateTagsRollback = new List<GanjoorPoemGeoDateTagCorrection>();
|
||||
foreach (var geoTag in currentCorrection.GeoDateTags.Where(g => g.Result == CorrectionReviewResult.Approved))
|
||||
{
|
||||
if (geoTag.MarkForDelete)
|
||||
{
|
||||
// the original request deleted an existing tag - undo that by re-adding a tag with
|
||||
// the same data, which was snapshotted onto this same record when it was approved
|
||||
// (LocationId/LunarYear/etc. are otherwise unused for a pure delete-request)
|
||||
geoDateTagsRollback.Add(new GanjoorPoemGeoDateTagCorrection()
|
||||
{
|
||||
CoupletIndex = geoTag.CoupletIndex,
|
||||
MarkForDelete = false,
|
||||
LocationId = geoTag.LocationId,
|
||||
LunarYear = geoTag.LunarYear,
|
||||
LunarMonth = geoTag.LunarMonth,
|
||||
LunarDay = geoTag.LunarDay,
|
||||
PersonId = geoTag.PersonId,
|
||||
IgnoreInCategory = geoTag.IgnoreInCategory,
|
||||
SuggestionNote = $"برگشت حذف برچسب جغرافیایی/تاریخی با کد {correctionId}"
|
||||
});
|
||||
}
|
||||
else if (geoTag.ExistingTagId != null)
|
||||
{
|
||||
// the original request added a new tag - undo that by requesting deletion of the
|
||||
// live tag it produced (its id was recorded onto ExistingTagId when approved)
|
||||
geoDateTagsRollback.Add(new GanjoorPoemGeoDateTagCorrection()
|
||||
{
|
||||
CoupletIndex = geoTag.CoupletIndex,
|
||||
MarkForDelete = true,
|
||||
ExistingTagId = geoTag.ExistingTagId,
|
||||
SuggestionNote = $"برگشت افزودن برچسب جغرافیایی/تاریخی با کد {correctionId}"
|
||||
});
|
||||
}
|
||||
}
|
||||
if (geoDateTagsRollback.Count > 0)
|
||||
{
|
||||
correction.GeoDateTags = geoDateTagsRollback.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
correction.Note = $"برگشت تصحیح با کد {correctionId}";
|
||||
if (!string.IsNullOrEmpty(currentCorrection.Note))
|
||||
{
|
||||
|
||||
@ -680,12 +680,23 @@ namespace RMuseum.Services.Implementation
|
||||
|
||||
if (dbGeoDateTag.MarkForDelete)
|
||||
{
|
||||
// approving a delete-suggestion removes the existing, already-approved tag it targets
|
||||
// approving a delete-suggestion removes the existing, already-approved tag it targets.
|
||||
// before removing it, snapshot its data onto this correction row itself (reusing the
|
||||
// already-existing LocationId/LunarYear/etc. columns, which are otherwise unused for a
|
||||
// pure delete-request) - this is what lets a later "undo this correction" roll the
|
||||
// deletion back, since the live PoemGeoDateTag row won't exist to read from any more
|
||||
if (dbGeoDateTag.ExistingTagId != null)
|
||||
{
|
||||
var existingTag = await _context.PoemGeoDateTags.Where(t => t.Id == dbGeoDateTag.ExistingTagId).SingleOrDefaultAsync();
|
||||
if (existingTag != null)
|
||||
{
|
||||
dbGeoDateTag.LocationId = existingTag.LocationId;
|
||||
dbGeoDateTag.LunarYear = existingTag.LunarYear;
|
||||
dbGeoDateTag.LunarMonth = existingTag.LunarMonth;
|
||||
dbGeoDateTag.LunarDay = existingTag.LunarDay;
|
||||
dbGeoDateTag.PersonId = existingTag.PersonId;
|
||||
dbGeoDateTag.IgnoreInCategory = existingTag.IgnoreInCategory;
|
||||
|
||||
_context.PoemGeoDateTags.Remove(existingTag);
|
||||
}
|
||||
}
|
||||
@ -724,6 +735,12 @@ namespace RMuseum.Services.Implementation
|
||||
};
|
||||
newTag.LunarDateTotalNumber = _PrepareLunarDateTotalNumber(newTag);
|
||||
_context.PoemGeoDateTags.Add(newTag);
|
||||
await _context.SaveChangesAsync(); // need its Id below
|
||||
|
||||
// record which live tag this correction produced - repurposing ExistingTagId (normally
|
||||
// only meaningful for a delete-request) so that "undo this correction" can later find
|
||||
// and remove this exact tag, the same way it removes a newly-added verse or a title change
|
||||
dbGeoDateTag.ExistingTagId = newTag.Id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user