#457 making the api more freindly

This commit is contained in:
Hamid Reza Mohammadi 2025-01-10 14:38:15 +03:30
parent cbc14aa78d
commit c87b1e91c9
4 changed files with 16 additions and 16 deletions

View File

@ -2282,17 +2282,17 @@ namespace RMuseum.Controllers
/// <summary>
/// add a new item to an artifact
/// </summary>
/// <param name="artifactId"></param>
/// <param name="artifactFriendlyUrl"></param>
/// <param name="jpeg"></param>
/// <returns></returns>
[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<IActionResult> AddItemToArtifactAsync(Guid artifactId, IFormFile jpeg)
public async Task<IActionResult> 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);

View File

@ -674,11 +674,11 @@
</summary>
<returns></returns>
</member>
<member name="M:RMuseum.Controllers.ArtifactController.AddItemToArtifactAsync(System.Guid,Microsoft.AspNetCore.Http.IFormFile)">
<member name="M:RMuseum.Controllers.ArtifactController.AddItemToArtifactAsync(System.String,Microsoft.AspNetCore.Http.IFormFile)">
<summary>
add a new item to an artifact
</summary>
<param name="artifactId"></param>
<param name="artifactFriendlyUrl"></param>
<param name="jpeg"></param>
<returns></returns>
</member>
@ -15347,11 +15347,11 @@
create images for ganjoor - offline
</summary>
</member>
<member name="M:RMuseum.Services.IArtifactService.AddItemToArtifactAsync(System.Guid,Microsoft.AspNetCore.Http.IFormFile,System.IO.Stream)">
<member name="M:RMuseum.Services.IArtifactService.AddItemToArtifactAsync(System.String,Microsoft.AspNetCore.Http.IFormFile,System.IO.Stream)">
<summary>
add item to an artifact
</summary>
<param name="artifactId"></param>
<param name="artifactFriendlyUrl">ai</param>
<param name="file"></param>
<param name="jpegStream"></param>
<returns></returns>
@ -18038,11 +18038,11 @@
<param name="term"></param>
<returns></returns>
</member>
<member name="M:RMuseum.Services.Implementation.ArtifactService.AddItemToArtifactAsync(System.Guid,Microsoft.AspNetCore.Http.IFormFile,System.IO.Stream)">
<member name="M:RMuseum.Services.Implementation.ArtifactService.AddItemToArtifactAsync(System.String,Microsoft.AspNetCore.Http.IFormFile,System.IO.Stream)">
<summary>
add item to an artifact
</summary>
<param name="artifactId"></param>
<param name="artifactFriendlyUrl"></param>
<param name="file"></param>
<param name="jpegStream"></param>
<returns></returns>

View File

@ -633,11 +633,11 @@ namespace RMuseum.Services
/// <summary>
/// add item to an artifact
/// </summary>
/// <param name="artifactId"></param>
/// <param name="artifactFriendlyUrl">ai</param>
/// <param name="file"></param>
/// <param name="jpegStream"></param>
/// <returns></returns>
Task<RServiceResult<RArtifactItemRecord>> AddItemToArtifactAsync(Guid artifactId, IFormFile file, Stream jpegStream);
Task<RServiceResult<RArtifactItemRecord>> AddItemToArtifactAsync(string artifactFriendlyUrl, IFormFile file, Stream jpegStream);
}
}

View File

@ -3637,16 +3637,16 @@ namespace RMuseum.Services.Implementation
/// <summary>
/// add item to an artifact
/// </summary>
/// <param name="artifactId"></param>
/// <param name="artifactFriendlyUrl"></param>
/// <param name="file"></param>
/// <param name="jpegStream"></param>
/// <returns></returns>
public async Task<RServiceResult<RArtifactItemRecord>> AddItemToArtifactAsync(Guid artifactId, IFormFile file, Stream jpegStream)
public async Task<RServiceResult<RArtifactItemRecord>> 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)
{