Refactor controllers to use route parameters for UpdateAsync methods and improve consistency in model retrieval

This commit is contained in:
2025-11-13 21:31:49 +00:00
parent 4a2d46f3b0
commit 76bebc68b7
26 changed files with 72 additions and 72 deletions

View File

@@ -100,18 +100,18 @@ public class MachinePhotosController(MarechaiContext context) : ControllerBase
})
.FirstOrDefaultAsync();
[HttpPost]
[HttpPut("{id:Guid}")]
[Authorize(Roles = "Admin,UberAdmin")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
public async Task<ActionResult> UpdateAsync([FromBody] MachinePhotoDto dto)
public async Task<ActionResult> UpdateAsync(Guid id, [FromBody] MachinePhotoDto dto)
{
string userId = User.FindFirstValue(ClaimTypes.Sid);
if(userId is null) return Unauthorized();
MachinePhoto model = await context.MachinePhotos.FindAsync(dto.Id);
MachinePhoto model = await context.MachinePhotos.FindAsync(id);
if(model is null) return NotFound();