// src/Webshop.Api/Controllers/Admin/AdminShopInfoController.cs
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System.Threading.Tasks;
using Webshop.Application.DTOs.Shop;
using Webshop.Application.Services.Admin;
namespace Webshop.Api.Controllers.Admin
{
///
/// API-Endpunkte zur Verwaltung der zentralen Shop-Stammdaten.
///
[ApiController]
[Route("api/v1/admin/[controller]")]
[Authorize(Roles = "Admin")]
public class AdminShopInfoController : ControllerBase
{
private readonly IAdminShopInfoService _shopInfoService;
public AdminShopInfoController(IAdminShopInfoService shopInfoService)
{
_shopInfoService = shopInfoService;
}
///
/// Ruft die aktuellen Stammdaten des Shops ab.
///
///
/// Diese Daten werden typischerweise in einem "Stammdaten"- oder "Shop-Einstellungen"-Formular im Admin-Dashboard angezeigt.
///
[HttpGet]
public async Task> GetShopInfo()
{
var info = await _shopInfoService.GetShopInfoAsync();
return Ok(info);
}
///
/// Aktualisiert die zentralen Stammdaten des Shops.
///
///
/// Sendet das gesamte, ausgefüllte DTO. Alle Felder werden überschrieben.
///
/// Das Datenobjekt mit den neuen Shop-Informationen.
[HttpPut]
public async Task UpdateShopInfo([FromBody] AdminShopInfoDto shopInfoDto)
{
if (!ModelState.IsValid)
{
return BadRequest(ModelState);
}
await _shopInfoService.UpdateShopInfoAsync(shopInfoDto);
return NoContent();
}
}
}