removing bookmarks and notes for a deleting artifact
This commit is contained in:
parent
2c1114c331
commit
afad3d4f3a
@ -243,9 +243,9 @@ namespace RMuseum.Controllers
|
||||
[ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(bool))]
|
||||
[ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))]
|
||||
[ProducesResponseType((int)HttpStatusCode.Forbidden)]
|
||||
public async Task<IActionResult> RemoveArtifactHavingNoNoteAndBookmarks(Guid artifactId)
|
||||
public async Task<IActionResult> RemoveArtifact(Guid artifactId)
|
||||
{
|
||||
RServiceResult<bool> res = await _artifactService.RemoveArtifactHavingNoNoteAndBookmarks(artifactId, true);
|
||||
RServiceResult<bool> res = await _artifactService.RemoveArtifact(artifactId, true);
|
||||
if (!string.IsNullOrEmpty(res.ExceptionString))
|
||||
{
|
||||
return BadRequest(res.ExceptionString);
|
||||
|
||||
@ -50,7 +50,7 @@
|
||||
<param name="friendlyUrl"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Controllers.ArtifactController.RemoveArtifactHavingNoNoteAndBookmarks(System.Guid)">
|
||||
<member name="M:RMuseum.Controllers.ArtifactController.RemoveArtifact(System.Guid)">
|
||||
<summary>
|
||||
remove unpublished artifact having no notes and not bookmarked
|
||||
</summary>
|
||||
@ -8906,7 +8906,7 @@
|
||||
<param name="linkId"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.IArtifactService.RemoveArtifactHavingNoNoteAndBookmarks(System.Guid,System.Boolean)">
|
||||
<member name="M:RMuseum.Services.IArtifactService.RemoveArtifact(System.Guid,System.Boolean)">
|
||||
<summary>
|
||||
an incomplete prototype for removing artifacts
|
||||
</summary>
|
||||
@ -10281,7 +10281,7 @@
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.Implementation.ArtifactService.RemoveArtifactHavingNoNoteAndBookmarks(System.Guid,System.Boolean)">
|
||||
<member name="M:RMuseum.Services.Implementation.ArtifactService.RemoveArtifact(System.Guid,System.Boolean)">
|
||||
<summary>
|
||||
an incomplete prototype for removing artifacts
|
||||
</summary>
|
||||
|
||||
@ -518,7 +518,7 @@ namespace RMuseum.Services
|
||||
/// <param name="artifactId"></param>
|
||||
/// <param name="checkJobs"></param>
|
||||
/// <returns></returns>
|
||||
Task<RServiceResult<bool>> RemoveArtifactHavingNoNoteAndBookmarks(Guid artifactId, bool checkJobs);
|
||||
Task<RServiceResult<bool>> RemoveArtifact(Guid artifactId, bool checkJobs);
|
||||
|
||||
/// <summary>
|
||||
/// start filling GanjoorLink table OriginalSource values
|
||||
|
||||
@ -598,7 +598,7 @@ namespace RMuseum.Services.Implementation
|
||||
scheduled = new List<string>();
|
||||
foreach (ImportJob job in rescheduledJobs)
|
||||
{
|
||||
await RemoveArtifactHavingNoNoteAndBookmarks((Guid)job.ArtifactId, false);
|
||||
await RemoveArtifact((Guid)job.ArtifactId, false);
|
||||
_context.ImportJobs.Remove(job);
|
||||
await _context.SaveChangesAsync();
|
||||
RServiceResult<bool> rescheduled = await StartImportingFromTheLibraryOfCongress(job.ResourceNumber, job.FriendlyUrl, "rbc0001");//plmp
|
||||
|
||||
@ -1224,15 +1224,10 @@ namespace RMuseum.Services.Implementation
|
||||
/// <param name="artifactId"></param>
|
||||
/// <param name="checkJobs"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<RServiceResult<bool>> RemoveArtifactHavingNoNoteAndBookmarks(Guid artifactId, bool checkJobs)
|
||||
public async Task<RServiceResult<bool>> RemoveArtifact(Guid artifactId, bool checkJobs)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (await _context.UserBookmarks.Where(b => b.RArtifactMasterRecordId == artifactId).AnyAsync())
|
||||
return new RServiceResult<bool>(false, "The artifcat is bookmarked by somebody and cannot be deleted");
|
||||
if (await _context.UserNotes.Where(n => n.RArtifactMasterRecordId == artifactId).AnyAsync())
|
||||
return new RServiceResult<bool>(false, "The artifcat has notes by somebody and cannot be deleted");
|
||||
|
||||
RArtifactMasterRecord record = await _context.Artifacts
|
||||
.Include(a => a.Items).ThenInclude(i => i.Images)
|
||||
.Include(a => a.Items).ThenInclude(i => i.Tags)
|
||||
@ -1248,7 +1243,16 @@ namespace RMuseum.Services.Implementation
|
||||
return new RServiceResult<bool>(false, "Can not delete published artifact");
|
||||
}
|
||||
|
||||
|
||||
if (await _context.UserBookmarks.Where(b => b.RArtifactMasterRecordId == artifactId).AnyAsync())
|
||||
{
|
||||
var bookmarks = await _context.UserBookmarks.Where(b => b.RArtifactMasterRecordId == artifactId).ToListAsync();
|
||||
_context.RemoveRange(bookmarks);
|
||||
}
|
||||
if (await _context.UserNotes.Where(n => n.RArtifactMasterRecordId == artifactId).AnyAsync())
|
||||
{
|
||||
var notes = await _context.UserNotes.Where(n => n.RArtifactMasterRecordId == artifactId).ToListAsync();
|
||||
_context.RemoveRange(notes);
|
||||
}
|
||||
|
||||
if (checkJobs)
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user