image änderungen
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user