Add player settings feature and settings API
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user