settings
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user