This commit is contained in:
Tizian.Breuch
2025-08-12 11:31:25 +02:00
parent 1692fe198e
commit bbea2458ae
10 changed files with 187 additions and 46 deletions

View File

@@ -1,10 +1,10 @@
// Auto-generiert von CreateWebshopFiles.ps1
using Microsoft.AspNetCore.Mvc;
// src/Webshop.Api/Controllers/Admin/AdminSettingsController.cs
using Microsoft.AspNetCore.Authorization;
using System;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Threading.Tasks;
using Webshop.Application.DTOs.Settings;
using Webshop.Application.Services.Admin.Interfaces;
namespace Webshop.Api.Controllers.Admin
{
@@ -13,6 +13,29 @@ namespace Webshop.Api.Controllers.Admin
[Authorize(Roles = "Admin")]
public class AdminSettingsController : ControllerBase
{
private readonly IAdminSettingService _adminSettingService;
public AdminSettingsController(IAdminSettingService adminSettingService)
{
_adminSettingService = adminSettingService;
}
[HttpGet]
public async Task<ActionResult<Dictionary<string, List<SettingDto>>>> GetAllSettings()
{
var settings = await _adminSettingService.GetAllGroupedAsync();
return Ok(settings);
}
[HttpPut]
public async Task<IActionResult> UpdateSettings([FromBody] List<SettingDto> settings)
{
if (!ModelState.IsValid)
{
return BadRequest(ModelState);
}
await _adminSettingService.UpdateSettingsAsync(settings);
return NoContent();
}
}
}
}

View File

@@ -128,6 +128,9 @@ builder.Services.AddScoped<ICheckoutService, CheckoutService>();
builder.Services.AddScoped<IReviewService, ReviewService>();
builder.Services.AddScoped<IAdminShopInfoService, AdminShopInfoService>();
builder.Services.AddScoped<IShopInfoService, ShopInfoService>();
builder.Services.AddScoped<ISettingService, SettingService>();
builder.Services.AddScoped<IAdminSettingService, AdminSettingService>();
// Controller und API-Infrastruktur
builder.Services.AddControllers()

View File

@@ -8,6 +8,10 @@
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
</PropertyGroup>
<ItemGroup>
<Content Include="Properties\launchSettings.json" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.18" />