diff --git a/RMuseum/Controllers/ArtifactController.cs b/RMuseum/Controllers/ArtifactController.cs index 7ee0057d..dcf48e19 100644 --- a/RMuseum/Controllers/ArtifactController.cs +++ b/RMuseum/Controllers/ArtifactController.cs @@ -2282,17 +2282,17 @@ namespace RMuseum.Controllers /// /// add a new item to an artifact /// - /// + /// /// /// - [HttpPut("item/{artifactId}")] + [HttpPut("item/{artifactFriendlyUrl}")] [Authorize(Policy = RMuseumSecurableItem.ArtifactEntityShortName + ":" + SecurableItem.ModifyOperationShortName)] [ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(RArtifactItemRecord))] [ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))] [ProducesResponseType((int)HttpStatusCode.Unauthorized)] - public async Task AddItemToArtifactAsync(Guid artifactId, IFormFile jpeg) + public async Task AddItemToArtifactAsync(string artifactFriendlyUrl, IFormFile jpeg) { - var res = await _artifactService.AddItemToArtifactAsync(artifactId, jpeg, null); + var res = await _artifactService.AddItemToArtifactAsync(artifactFriendlyUrl, jpeg, null); if (!string.IsNullOrEmpty(res.ExceptionString)) return BadRequest(res.ExceptionString); return Ok(res.Result); diff --git a/RMuseum/RMuseum.xml b/RMuseum/RMuseum.xml index 1c26ac0c..318304d6 100644 --- a/RMuseum/RMuseum.xml +++ b/RMuseum/RMuseum.xml @@ -674,11 +674,11 @@ - + add a new item to an artifact - + @@ -15347,11 +15347,11 @@ create images for ganjoor - offline - + add item to an artifact - + ai @@ -18038,11 +18038,11 @@ - + add item to an artifact - + diff --git a/RMuseum/Services/IArtifactService.cs b/RMuseum/Services/IArtifactService.cs index 20df466b..21f2da1c 100644 --- a/RMuseum/Services/IArtifactService.cs +++ b/RMuseum/Services/IArtifactService.cs @@ -633,11 +633,11 @@ namespace RMuseum.Services /// /// add item to an artifact /// - /// + /// ai /// /// /// - Task> AddItemToArtifactAsync(Guid artifactId, IFormFile file, Stream jpegStream); + Task> AddItemToArtifactAsync(string artifactFriendlyUrl, IFormFile file, Stream jpegStream); } } diff --git a/RMuseum/Services/Implementation/ArtifactService.cs b/RMuseum/Services/Implementation/ArtifactService.cs index b44ecfa5..933e2969 100644 --- a/RMuseum/Services/Implementation/ArtifactService.cs +++ b/RMuseum/Services/Implementation/ArtifactService.cs @@ -3637,16 +3637,16 @@ namespace RMuseum.Services.Implementation /// /// add item to an artifact /// - /// + /// /// /// /// - public async Task> AddItemToArtifactAsync(Guid artifactId, IFormFile file, Stream jpegStream) + public async Task> AddItemToArtifactAsync(string artifactFriendlyUrl, IFormFile file, Stream jpegStream) { try { - RArtifactMasterRecord book = await _context.Artifacts.Where(b => b.Id == artifactId).SingleAsync(); - RArtifactItemRecord firstItem = await _context.Items.AsNoTracking().Where(i => i.RArtifactMasterRecordId == artifactId).FirstOrDefaultAsync(); + RArtifactMasterRecord book = await _context.Artifacts.Where(b => b.FriendlyUrl == artifactFriendlyUrl).SingleAsync(); + RArtifactItemRecord firstItem = await _context.Items.AsNoTracking().Where(i => i.RArtifactMasterRecordId == book.Id).FirstOrDefaultAsync(); int zeroPads = 4; if(firstItem != null) {