Files
TenWholeYears.Server/src/API/Controllers/Settings/V1/SettingsController.cs
T
2026-06-20 22:58:33 -05:00

41 lines
1.1 KiB
C#

using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using RecNet.Application.Common.Security;
using RecNet.Application.Profiles;
namespace API.Controllers.Settings.V1;
[Authorize]
[ApiController]
[Route("api/[controller]/v1")]
public class SettingsController(IProfileService profileService) : ControllerBase
{
[HttpGet]
public async Task<IReadOnlyList<PlayerSettingDTO>> GetAllAsync(CancellationToken ct)
{
var profileId = User.GetProfileId();
return await profileService.GetPlayerSettingsAsync(profileId, ct);
}
[HttpPost("set")]
public async Task<IActionResult> SetAsync(
[FromBody] PlayerSettingDTO request,
CancellationToken ct)
{
var profileId = User.GetProfileId();
var updated = await profileService.UpdatePlayerSettingAsync
(
profileId: profileId,
command: new UpdatePlayerSettingCommand(request.Key, request.Value),
ct: ct
);
if (!updated)
return NotFound();
return Ok();
}
}