image änderungen

This commit is contained in:
Tizian.Breuch
2025-08-06 10:42:32 +02:00
parent 2475e896b9
commit 7ff593cfcf
16 changed files with 427 additions and 172 deletions

View File

@@ -6,6 +6,7 @@ using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Webshop.Application.DTOs.Products;
using Microsoft.AspNetCore.Http;
using Webshop.Application.Services.Admin.Interfaces;
namespace Webshop.Api.Controllers.Admin
@@ -38,15 +39,25 @@ namespace Webshop.Api.Controllers.Admin
}
[HttpPost]
public async Task<ActionResult<AdminProductDto>> CreateAdminProduct([FromBody] AdminProductDto productDto)
[Consumes("multipart/form-data")] /
public async Task<ActionResult<AdminProductDto>> CreateAdminProduct([FromForm] CreateAdminProductDto productDto) // << NEU: [FromForm] und CreateAdminProductDto >>
{
if (!ModelState.IsValid) return BadRequest(ModelState);
var createdProduct = await _adminProductService.CreateAdminProductAsync(productDto);
if (createdProduct == null)
{
// Hier k<>nnte eine spezifischere Fehlermeldung vom Service kommen
return BadRequest("Produkt konnte nicht erstellt werden.");
}
return CreatedAtAction(nameof(GetAdminProduct), new { id = createdProduct.Id }, createdProduct);
}
[HttpPut("{id}")]
public async Task<IActionResult> UpdateAdminProduct(Guid id, [FromBody] AdminProductDto productDto)
public async Task<IActionResult> UpdateAdminProduct(Guid id, [FromBody] UpdateAdminProductDto productDto)
{
if (id != productDto.Id) return BadRequest();
if (!ModelState.IsValid) return BadRequest(ModelState);